CUPiD icon indicating copy to clipboard operation
CUPiD copied to clipboard

Create a cupid-remap script for regridding

Open mnlevy1981 opened this issue 8 months ago • 4 comments

Is your feature request related to a problem? Please describe. Similar to how cupid-timeseries just calls ncrcat, cupid-remap could call ncremap. The config file should include the path of the mapping file to use for each component (and the CESM workflow will need relative paths in env_postprocessing.xml to append to DIN_LOC_ROOT

Describe the solution you'd like The script needs to account for the following:

  1. CLM grids will call ncremap -P clm
  2. We will need to update the CESM workflow to add this step (and make sure ATM notebooks know whether to look in atm/proc/tseries or atm/proc/tseries/regrid)
  3. Update documentation

Additional context At some point we will want a python-based regridding script, so the python file we create in cupid might change but the workflow updates will still be useful

mnlevy1981 avatar Apr 01 '25 23:04 mnlevy1981

Adding a few notes from our hackathon:

  • Mike was working on making sure that cupid-remap would be both component and case specific
  • Will mentioned that, when remapping land files, we will need to use the weight file after remapping for some calculations/plotting

TeaganKing avatar Jun 05 '25 16:06 TeaganKing

Hi, Mike and Teagan, I tried to setup the config.yml and use `cupid-remap' as stand-alone (not in the CESM workflow type) to do the remapping of time series file to regridded file. However, it runs without error but neither output. Could you help to figure out what can be the problem?

cupid-remap log:

$ cupid-remap -lnd ./config.yml
INFO:cupid.util:
  Regridding lnd time series files...
INFO:cupid.util:	 Regridding time series for case 'n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729' :
INFO:cupid.util:	 Regridding time series for case 'n1850.ne30_tn14.cplhist.3_0_a03b.20250606' :
INFO:cupid.util:  ... lnd time series file remapping has finished successfully.

config.yml snippet:

global_params:
  case_name: 'n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729'
  base_case_name: 'n1850.ne30_tn14.cplhist.3_0_a03b.20250606'
  CESM_output_dir: /nird/datalake/NS9560K/noresm3/tseries
...
...
timeseries:
...
lnd:
    vars: ['SOILWATER_10CM','mrsos',
           'FSH_TO_COUPLER',
          'TOTVEGC','cVeg','biomass',
          ...]
...
   start_years: [101]
    end_years: [121]
    level: 'lev'
    mapping_file: ['/nird/datalake/NS16000B/inputdata/cpl/gridmaps/ne30pg3/map_ne30pg3_to_0.5x0.5_nomask_aave_da_c180515.nc']
...

btw, do I need to specify the 'start_years' ('end_years') with a list of the same numbers for each of the included variables, or I can use one to be repeatedly used for all variables?

Thanks for the help!

Yanchun

YanchunHe avatar Aug 21 '25 10:08 YanchunHe

I think the default output directory for remapping is based on CESM_output_dir, case_name, and the component name; was your history output in /nird/datalake/NS9560K/noresm3/tseries/n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729/lnd/hist? If so, I would expect time series output in /nird/datalake/NS9560K/noresm3/tseries/n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729/lnd/proc/tseries and the regridded output to be in /nird/datalake/NS9560K/noresm3/tseries/n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729/lnd/proc/tseries/regrid

Does lnd/proc exist? How about lnd/proc/tseries? If so, what's in that directory?

mnlevy1981 avatar Aug 21 '25 23:08 mnlevy1981

Thanks for the reply @mnlevy1981

Yes, I have lnd/hist and lnd/proc, see:

noresm3/tseries/n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729
$ tree -L 3
.
├── atm
│   ├── hist -> ../../../cases/n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729/atm/hist
│   └── proc
│       └── tseries
├── ice
│   └── hist -> ../../../cases/n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729/ice/hist
├── lnd
│   ├── hist -> ../../../cases/n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729/lnd/hist
│   └── proc
│       ├── regrid
│       └── tseries
├── ocn
│   └── hist -> ../../../cases/n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729/ocn/hist
└── rof
    └── hist -> ../../../cases/n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729/rof/hist

16 directories, 0 files

And have ts files under the tseries:

$ cd lnd/proc/tseries
$ ls
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.EFLX_LH_TOT.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FGR12.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FIRE.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FLDS.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FSA.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FSDS.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FSH.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FSH_TO_COUPLER.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FSR.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.H2OSNO.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.QRUNOFF.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.RH2M.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.SOILWATER_10CM.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TLAI.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TOTSOMC_1m.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TREFMNAV.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TREFMXAV.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TSA.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TSOI.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TWS.010101-012012.nc

The cupid-remap does not produce any remapped file under proc/regrid, but I then mannually run ncremap to get some regridded file.

$ cd ../regrid
$ ls
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.EFLX_LH_TOT.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FGR12.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FIRE.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FLDS.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FSA.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FSDS.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FSH.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FSH_TO_COUPLER.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.FSR.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.H2OSNO.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.QRUNOFF.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.RH2M.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.SOILWATER_10CM.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TLAI.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TOTSOMC_1m.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TREFMNAV.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TREFMXAV.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TSA.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TSOI.010101-012012.nc
n1850.ne30_tn14.nor3_b01-noLU_yr101.20250729.h0.TWS.010101-012012.nc

But as I said, I don't know why cupid-remap does not work.

Are there some more detailed log files that I can look into?

YanchunHe avatar Aug 22 '25 11:08 YanchunHe