@@ -70,23 +70,23 @@ def plot_diff_scans(self,measurandstring,dataset,dataset_avg=None):
7070 dataset .attrs ['product_name' ]+ "_series_" + str (
7171 series_id [i ])+ "." + self .context .get_config_value ("plotting_format" ))
7272
73- ids = np .where (dataset ['series_id' ] == series_id [i ])
73+ ids = np .where (dataset ['series_id' ] == series_id [i ])[ 0 ]
7474
7575 ydata_subset = dataset [measurandstring ].values [:,ids ]
7676 mask = DatasetUtil .unpack_flags (dataset ["quality_flag" ])["outliers" ]
77+ mask = mask [ids ]
78+
7779 if dataset_avg is None :
7880 ids_used = np .where ((dataset ['series_id' ] == series_id [i ]) & np .invert (
7981 DatasetUtil .unpack_flags (dataset ["quality_flag" ])["outliers" ]))[0 ]
8082 ydata_subset_used = dataset [measurandstring ].values [:,ids_used ]
81- avgs = np .tile (np .mean (ydata_subset_used ,axis = 1 )[...,None ],len (ids_used ))
82- mask = mask [ids_used ]
83+ avgs = np .tile (np .mean (ydata_subset_used ,axis = 1 )[...,None ],len (ids ))
8384 else :
8485 avg_ids = np .where ((dataset_avg ['series_id' ] == series_id [i ]))[0 ]
85- avgs = np .tile (dataset_avg [measurandstring ].values [:,avg_ids ],len (avg_ids ))
86- mask = mask [avg_ids ]
86+ avgs = np .tile (dataset_avg [measurandstring ].values [:,avg_ids ],len (ids ))
8787
8888 self .plot_variable ("relative difference" ,plotpath ,dataset ["wavelength" ].values ,
89- (ydata_subset - avgs )/ avgs ,ylim = [- 0.2 ,0.2 ],mask = mask )
89+ (ydata_subset - avgs )/ avgs ,ylim = [- 0.3 ,0.3 ],mask = mask )
9090
9191 def plot_radiance (self ,plotpath ,xdata ,ydata ,labels = None ):
9292 fig1 ,ax1 = plt .subplots (figsize = (10 ,5 ))
@@ -99,7 +99,7 @@ def plot_radiance(self,plotpath,xdata,ydata,labels=None):
9999 ax1 .set_xlabel ("Wavelength (nm)" )
100100 ax1 .set_ylabel (r"Radiance ($mW\ nm^{-1}\ m^{-2}\ sr^{-1}$)" )
101101 ymax = np .percentile (ydata ,95 )* 1.2
102- ax1 .set_ylim ([0 ,max ( 1 , ymax ) ])
102+ ax1 .set_ylim ([0 ,ymax ])
103103 fig1 .savefig (plotpath ,bbox_inches = 'tight' )
104104 plt .close (fig1 )
105105
@@ -114,7 +114,7 @@ def plot_irradiance(self,plotpath,xdata,ydata,labels=None):
114114 ax1 .set_xlabel ("Wavelength (nm)" )
115115 ax1 .set_ylabel (r"Irradiance ($mW\ nm^{-1}\ m^{-2}$)" )
116116 ymax = np .percentile (ydata ,95 )* 1.2
117- ax1 .set_ylim ([0 ,max ( 100 , ymax ) ])
117+ ax1 .set_ylim ([0 ,ymax ])
118118 fig1 .savefig (plotpath ,bbox_inches = 'tight' )
119119 plt .close (fig1 )
120120
@@ -142,28 +142,32 @@ def plot_reflectance(self,plotpath,xdata,ydata,labels=None):
142142 ax1 .set_xlabel ("Wavelength (nm)" )
143143 ax1 .set_ylabel (r"Reflectance" )
144144 ymax = np .percentile (ydata ,95 )* 1.2
145- ax1 .set_ylim ([0 ,max ( 0.2 , ymax ) ])
145+ ax1 .set_ylim ([0 ,ymax ])
146146 fig1 .savefig (plotpath ,bbox_inches = 'tight' )
147147 plt .close (fig1 )
148148
149149 def plot_other_var (self ,measurandstring ,plotpath ,xdata ,ydata ,labels = None ,ylim = None ,mask = None ):
150150 fig1 ,ax1 = plt .subplots (figsize = (10 ,5 ))
151- if labels is None and mask is None or len (np .where (mask ))== 0 :
151+ if labels is None and mask is None or len (np .where (mask )[ 0 ] )== 0 :
152152 ax1 .plot (xdata ,ydata ,alpha = 0.3 )
153153 elif mask is None :
154154 for i in range (len (labels )):
155155 ax1 .plot (xdata ,ydata [:,i ],label = labels [i ],alpha = 0.3 )
156156 else :
157- print (ydata .shape )
158- print (ydata [:,np .where (np .invert (mask ))].shape ,ydata [:,np .where (np .invert (mask ))][:,0 ].shape )
159- ax1 .plot (xdata ,ydata [:,np .where (mask )].reshape ((len (ydata ),len (np .where (mask )[0 ]))),label = "masked" ,alpha = 0.3 )
160- ax1 .plot (xdata ,ydata [:,np .where (np .invert (mask ))].reshape ((len (ydata ),len (np .where (np .invert (mask ))[0 ]))),label = "used" ,alpha = 0.3 )
157+ print (len (np .where (mask )[0 ]))
158+ ax1 .plot (xdata ,ydata [:,np .where (mask )].reshape ((len (ydata ),len (np .where (mask )[0 ]))),label = "masked" ,alpha = 0.3 ,color = "red" )
159+ ax1 .plot (xdata ,ydata [:,np .where (np .invert (mask ))].reshape ((len (ydata ),len (np .where (np .invert (mask ))[0 ]))),label = "used" ,alpha = 0.3 ,color = "green" )
161160
162161 if labels is not None or mask is not None :
163- ax1 .legend ()
162+ handles ,labels = plt .gca ().get_legend_handles_labels ()
163+ by_label = dict (zip (labels ,handles ))
164+ ax1 .legend (by_label .values (),by_label .keys ())
164165 ax1 .set_xlabel ("Wavelength (nm)" )
165166 ax1 .set_ylabel (measurandstring )
166167 if ylim is not None :
167168 ax1 .set_ylim (ylim )
169+ else :
170+ ymax = np .percentile (ydata ,95 )* 1.2
171+ ax1 .set_ylim ([0 ,ymax ])
168172 fig1 .savefig (plotpath ,bbox_inches = 'tight' )
169173 plt .close (fig1 )
0 commit comments