ua-snap / cmip6-utils

Pipelines and utilites for working with CMIP6 data
1 stars 1 forks source link

Fix longitude in regridded files, add CRS info #35

Closed Joshdpaul closed 6 months ago

Joshdpaul commented 7 months ago

Revised 3/7/24: The standalone longitude correction / CRS script has been rolled into the main regrid.py function instead!

This PR closes #25 and closes #30

The regrid.py script now includes:

TO TEST:

import xarray as xr
import rasterio

fp = '/Users/joshpaul/Desktop/SNAP/CMIP6/qgis2/pr_day_CESM2_ssp126_regrid_20700101-20701231.nc'
ds = xr.open_dataset(fp, decode_coords="all")

print(ds.rio.crs)

Things to note:
The longitude attributes in the regridded .nc files may still reference values 0-360, since this branch does not include the attribute fixes yet. You may also see some warnings if opening the regridded files with xarray.open_dataset(decode_coords='all') that stem from non-standard attributes.

Future work: Now that we have slurm outputs that are searchable (ie, have standardized error messaging), we can include them in a QC process similar to the indicators Prefect flow. After the jobs complete in the Prefect flow, we can look for the "retry" file and try any bad files a second time. Thats probably also the point in the flow where we can address this issue about stuck jobs, maybe setting a time limit for a batch to complete and adding the files to the "retry" batch if it gets stuck.

Exploratory notebooks: These were updated in this branch and @kyleredilla and I were messing with NaN values, grids, extrapolation, etc. That work is going to be committed here but is really part of a different grid selection problem that will be solved in other branches.