Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small changes to OMPS nadir mapper level 2 reader #199

Merged
merged 11 commits into from
Oct 7, 2024
33 changes: 19 additions & 14 deletions monetio/sat/_omps_nadir_mm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,35 @@ def read_OMPS_nm(files):
import xarray as xr

count = 0
print(files)
# Check if files are url
if "https" in files[0]:
filelist = sorted(files)
for filename in filelist:
data = extract_OMPS_nm_opendap(filename)
# print(data)
if count == 0:
data_array = data
count += 1
else:
data_array = xr.concat([data_array, data], "x")
else:
filelist = sorted(glob(files, recursive=False))

for filename in filelist:
data = extract_OMPS_nm(filename)

if count == 0:
data_array = data
count += 1
else:
data_array = xr.concat([data_array, data], "x")

else: # using local files
if isinstance(files, str): # expansion of filestring to list
filelist = sorted(glob(files, recursive=False))
else: # ensure provided filelist is sorted
filelist = sorted(files) # assume list
for filename in filelist: # extract data
try:
data = extract_OMPS_nm(filename)
if count == 0:
data_array = data
count += 1
else:
data_array = xr.concat([data_array, data], "x")
zmoon marked this conversation as resolved.
Show resolved Hide resolved
except (KeyError, ValueError) as e:
# KeyError occurs in load when file exists but contains no data
# ValueError occurs in concat when file cross-track dimensions are different than other files loaded
print(f"warning: skipping {filename}. {type(e).__name__} occurred: {e}")
if count == 0:
raise RuntimeError(f"no files loaded from files={files}")
return data_array
mbruckner-work marked this conversation as resolved.
Show resolved Hide resolved


Expand Down
Loading