Loading py/cso_s5p.py +26 −19 Original line number Diff line number Diff line Loading @@ -49,6 +49,12 @@ # 2024-08, Arjo Segers # Show info on number of remaining pixels after applying filter. # # 2024-09, Arjo Segers # Fixed slection descriptions written to history attribute. # Fixed replacement of units for special procedssing 'square_sum'. # Fixed check on inquire filedates in case of multiple inquire files. # ######################################################################## ### Loading Loading @@ -485,7 +491,7 @@ class S5p_File(object): # apply filter: selected = selected & (xdata == fvalue) # update history, also select on not-nan to avoid warnings from comparisons: history.append("selected pixels with '{varname}' == {svalue}") history.append(f"selected pixels with '{varname}' == {svalue}") # elif filtertype == "ratio_square": try: Loading Loading @@ -534,7 +540,7 @@ class S5p_File(object): # apply filter, also select on not-nan to avoid warnings from comparisons: selected = selected & (xdata >= fmin) # update history: history.append("selected pixels with '{varname}' >= {smin}") history.append(f"selected pixels with '{varname}' >= {smin}") # # ~ maximum value: elif filtertype == "max": Loading Loading @@ -584,7 +590,7 @@ class S5p_File(object): # apply filter, also select on not-nan to avoid warnings from comparisons: selected = selected & (xdata >= fmin) & (xdata <= fmax) # update history: history.append("selected pixels with '%s' in [%s,%s]" % (varname, smin, smax)) history.append(f"selected pixels with '{varname}' in [{smin},{smax}]") # # ~ only unmasked values: elif filtertype == "valid": Loading Loading @@ -1207,7 +1213,8 @@ class CSO_S5p_File(cso_file.CSO_File): if special == "square": # apply: da.data = da.data**2 da.attrs["units"] = "(%s)**2" % da.attrs["units"] units_in = da.attrs["units"] da.attrs["units"] = f"({units_in})**2" # endif # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Loading Loading @@ -1274,11 +1281,9 @@ class CSO_S5p_File(cso_file.CSO_File): # endif # postprocessing: if special == "square": # apply: da.data = da.data**2 da.attrs["units"] = "(%s)**2" % da.attrs["units"] # endif units_in = da.attrs["units"] da.attrs["units"] = f"({units_in})**2" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # time per pixel Loading Loading @@ -2710,15 +2715,19 @@ class CSO_S5p_Convert(utopya.UtopyaRc): logging.info(f"{indent}timerange: [%s,%s]" % (t1.strftime(tfmt), t2.strftime(tfmt))) # inquire tables: filename__templates = self.GetSetting("inquire.file").split(";") filename_key = self.GetSetting("inquire.file") filename__templates = filename_key.split(";") # time stamp in file? filedates = self.GetSetting("inquire.filedate", default="").split(";") if len(filedates) == 0: filedates_key = self.GetSetting("inquire.filedate", default="") if len(filedates_key) == 0: filedates = [""] * len(filename__templates) elif len(filedates) != len(filename__templates): logging.error("number of filedates should match with number of listing file names:") logging.error(" inquire.file : %s" % self.GetSetting("inquire.file")) logging.error(" inquire.filedate : %s" % self.GetSetting("inquire.filedate")) else : filedates = filedates_key.split(";") # endif if len(filedates) != len(filename__templates): logging.error(f"number of filedates should match with number of listing file names:") logging.error(f" inquire.file : {filename_key}") logging.error(f" inquire.filedate : {filedates_key}") raise Exception # endif # init storage: Loading Loading @@ -3128,9 +3137,7 @@ class CSO_S5p_Convert(utopya.UtopyaRc): sfile, selected, self.rcf, self.rcbase, indent=f"{indent} " ) # update history: history.append( "added %i pixels from %s" % (nselected, os.path.basename(input_file)) ) history.append(f"added {nselected} pixels from {os.path.basename(input_file)}") # update attributes: for key in ["orbit", "processing", "processor_version", "collection"]: attrs[key] = rec[key] Loading Loading
py/cso_s5p.py +26 −19 Original line number Diff line number Diff line Loading @@ -49,6 +49,12 @@ # 2024-08, Arjo Segers # Show info on number of remaining pixels after applying filter. # # 2024-09, Arjo Segers # Fixed slection descriptions written to history attribute. # Fixed replacement of units for special procedssing 'square_sum'. # Fixed check on inquire filedates in case of multiple inquire files. # ######################################################################## ### Loading Loading @@ -485,7 +491,7 @@ class S5p_File(object): # apply filter: selected = selected & (xdata == fvalue) # update history, also select on not-nan to avoid warnings from comparisons: history.append("selected pixels with '{varname}' == {svalue}") history.append(f"selected pixels with '{varname}' == {svalue}") # elif filtertype == "ratio_square": try: Loading Loading @@ -534,7 +540,7 @@ class S5p_File(object): # apply filter, also select on not-nan to avoid warnings from comparisons: selected = selected & (xdata >= fmin) # update history: history.append("selected pixels with '{varname}' >= {smin}") history.append(f"selected pixels with '{varname}' >= {smin}") # # ~ maximum value: elif filtertype == "max": Loading Loading @@ -584,7 +590,7 @@ class S5p_File(object): # apply filter, also select on not-nan to avoid warnings from comparisons: selected = selected & (xdata >= fmin) & (xdata <= fmax) # update history: history.append("selected pixels with '%s' in [%s,%s]" % (varname, smin, smax)) history.append(f"selected pixels with '{varname}' in [{smin},{smax}]") # # ~ only unmasked values: elif filtertype == "valid": Loading Loading @@ -1207,7 +1213,8 @@ class CSO_S5p_File(cso_file.CSO_File): if special == "square": # apply: da.data = da.data**2 da.attrs["units"] = "(%s)**2" % da.attrs["units"] units_in = da.attrs["units"] da.attrs["units"] = f"({units_in})**2" # endif # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Loading Loading @@ -1274,11 +1281,9 @@ class CSO_S5p_File(cso_file.CSO_File): # endif # postprocessing: if special == "square": # apply: da.data = da.data**2 da.attrs["units"] = "(%s)**2" % da.attrs["units"] # endif units_in = da.attrs["units"] da.attrs["units"] = f"({units_in})**2" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # time per pixel Loading Loading @@ -2710,15 +2715,19 @@ class CSO_S5p_Convert(utopya.UtopyaRc): logging.info(f"{indent}timerange: [%s,%s]" % (t1.strftime(tfmt), t2.strftime(tfmt))) # inquire tables: filename__templates = self.GetSetting("inquire.file").split(";") filename_key = self.GetSetting("inquire.file") filename__templates = filename_key.split(";") # time stamp in file? filedates = self.GetSetting("inquire.filedate", default="").split(";") if len(filedates) == 0: filedates_key = self.GetSetting("inquire.filedate", default="") if len(filedates_key) == 0: filedates = [""] * len(filename__templates) elif len(filedates) != len(filename__templates): logging.error("number of filedates should match with number of listing file names:") logging.error(" inquire.file : %s" % self.GetSetting("inquire.file")) logging.error(" inquire.filedate : %s" % self.GetSetting("inquire.filedate")) else : filedates = filedates_key.split(";") # endif if len(filedates) != len(filename__templates): logging.error(f"number of filedates should match with number of listing file names:") logging.error(f" inquire.file : {filename_key}") logging.error(f" inquire.filedate : {filedates_key}") raise Exception # endif # init storage: Loading Loading @@ -3128,9 +3137,7 @@ class CSO_S5p_Convert(utopya.UtopyaRc): sfile, selected, self.rcf, self.rcbase, indent=f"{indent} " ) # update history: history.append( "added %i pixels from %s" % (nselected, os.path.basename(input_file)) ) history.append(f"added {nselected} pixels from {os.path.basename(input_file)}") # update attributes: for key in ["orbit", "processing", "processor_version", "collection"]: attrs[key] = rec[key] Loading