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

[QUESTION]Selection of interpolation method in ESMF_RegridWeightGen #258

Closed
helpyuan opened this issue Sep 6, 2023 · 14 comments · Fixed by #266
Closed

[QUESTION]Selection of interpolation method in ESMF_RegridWeightGen #258

helpyuan opened this issue Sep 6, 2023 · 14 comments · Fixed by #266
Assignees
Labels
category: Question A question submitted by a user topic: Regridding Issues pertaining to horizontal & vertical regridding topic: User Environment Relating to python and/or conda environment

Comments

@helpyuan
Copy link

helpyuan commented Sep 6, 2023

Type your question below:

Hi all, I hope to convert a lat/lon grid restart file to a cubed-sphere grid restart file. I followed the tutorials on https://gcpy.readthedocs.io/en/stable/Regridding.html, but the tutorial only provides regerid examples for cubed sphere. The "ESMF_RegridWeightGen --method" for regrinding between a cube-sphere(c48) and a cube-sphere(c60) is "conserve", and a "stretched cubed-sphere" and "cubed-sphere" is also "conserve". But I don't know if the regrid method between "lat/lon" and "cubed-sphere" is also 'conserved', or if is it bilinear.
I sincerely hope to receive your help.

@helpyuan helpyuan added the category: Question A question submitted by a user label Sep 6, 2023
@yantosca yantosca added topic: User Environment Relating to python and/or conda environment topic: Regridding Issues pertaining to horizontal & vertical regridding labels Sep 6, 2023
@yantosca yantosca self-assigned this Sep 6, 2023
@yantosca
Copy link
Contributor

yantosca commented Sep 6, 2023

Thanks @helpyuan. If you download the code in the dev branch (instead of main), the LL to CS regridding will work with the file_regrid.py routine. Also see the new instructions on the "latest" documentation:

NOTE: You will have to build a new Python environment using Mambaforge. The instructions are here:

We will hopefully release this as GCPy 1.4.0 along (or soon thereafter) the GEOS-Chem 14.2.0/14.2.1 updates.

Part of the reason that the regridding was broken in the current GCPy release was due to Python package updates that broke backwards compatibility. We seem to have gotten around this by using MambaForge instead of Conda to install the python environment.

Let us know if you encounter any further problems!

@yantosca
Copy link
Contributor

yantosca commented Sep 6, 2023

Also I think the lat-lon and cubed-sphere regridding is conservative. Tagging @lizziel.

@lizziel
Copy link
Contributor

lizziel commented Sep 6, 2023

You can also take a look at the ESMF docs for ESMF_RegridWeightGen directly here. The function is not part of GCPy, but is actually part of ESMF. The docs will include all options for the function.

@helpyuan
Copy link
Author

helpyuan commented Sep 7, 2023

Thanks @yantosca and @lizziel.

I have been able to regrid LL to CS, but the output does not include the variable "lon". What should I do to make the output result have the variable "lon" ? The output file variables are as follows:
regrid_cs_ncfile.log.txt

In addition, this website ((https://gcpy.readthedocs.io/en/latest/Regridding.html) introduces two methods for regriding LL to CS, one of which is gcpy.regrid_restart_file, a function is gcpy.file_regrid. I would like to ask if both of these methods can currently regrid the GC-Classic restart file to the GCHP executable restart file?

@lizziel
Copy link
Contributor

lizziel commented Sep 7, 2023

Hi @helpyuan, could you write out the steps you took to regrid LL to CS, including information on the source file?

Both of the options on ReadTheDocs should work for regridding LL to CS. However, if you run into any issues let us know.

@helpyuan
Copy link
Author

helpyuan commented Sep 8, 2023

Hi @lizziel, I used gcpy.file_regrid to regrid LL to CS and my steps are as follows:

python -m gcpy.file_regrid --filein ./GC-Classic/GEOSChem.Restart.TransportTracers.20190101_0000z.nc4 --dim_format_in classic --fileout GCHP.Restart.TransportTracers.20190101_0000z.c48.nc4 --cs_res_out 48 --dim_format_out checkpoint`

The print is as follows:

(gcpy_env) [liumy@ln2 regrid_restart_file]$ python -m gcpy.file_regrid --filein ./GC-Classic/GEOSChem.Restart.TransportTracers.20190101_0000z.nc4 --dim_format_in classic --fileout GCHP.Restart.TransportTracers.20190101_0000z.c48.nc4 --cs_res_out 48 --dim_format_out checkpoint
/data/home/liumy/tools/mambaforge-gcpy/GCPy/gcpy/file_regrid.py:13: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if LooseVersion(xe.__version__) < LooseVersion("0.2.1"):
using dimensions ('lat', 'lon') from data variable DELP_DRY as the horizontal dimensions for this dataset.
using dimensions ('lat', 'lon') from data variable DELP_DRY as the horizontal dimensions for this dataset.
using dimensions ('lat', 'lon') from data variable DELP_DRY as the horizontal dimensions for this dataset.
using dimensions ('lat', 'lon') from data variable DELP_DRY as the horizontal dimensions for this dataset.
using dimensions ('lat', 'lon') from data variable DELP_DRY as the horizontal dimensions for this dataset.
using dimensions ('lat', 'lon') from data variable DELP_DRY as the horizontal dimensions for this dataset.
<xarray.Dataset>
Dimensions:                       (time: 1, lev: 72, lat: 288, lon: 48)
Coordinates:
  * time                          (time) float64 0.0
  * lev                           (lev) float64 1.5e-05 2.635e-05 ... 0.9925
  * lat                           (lat) float64 1.0 2.0 3.0 ... 287.0 288.0
Dimensions without coordinates: lon
Data variables: (12/18)
    DELP_DRY                      (time, lev, lat, lon) float64 0.01 ... 15.22
    SPC_SHEmis90dayTracer         (time, lev, lat, lon) float64 1.498e-12 ......
    SPC_NHEmis90dayTracer         (time, lev, lat, lon) float64 1.722e-12 ......
    SPC_GlobEmis90dayTracer       (time, lev, lat, lon) float64 1.549e-12 ......
    SPC_COUniformEmis25dayTracer  (time, lev, lat, lon) float64 8.425e-17 ......
    SPC_COAnthroEmis50dayTracer   (time, lev, lat, lon) float64 9.743e-16 ......
    ...                            ...
    SPC_Be10                      (time, lev, lat, lon) float64 2.07e-18 ... ...
    SPC_Be7Strat                  (time, lev, lat, lon) float64 1.762e-19 ......
    SPC_Be7                       (time, lev, lat, lon) float64 1.762e-19 ......
    SPC_Pb210Strat                (time, lev, lat, lon) float64 4.576e-22 ......
    SPC_Pb210                     (time, lev, lat, lon) float64 5.675e-21 ......
    SPC_Rn222                     (time, lev, lat, lon) float64 0.0 ... 3.896...
Attributes: (12/14)
    title:                           GEOS-Chem diagnostic collection: Restart
    history:                         
    format:                          not found
    conventions:                     COARDS
    ProdDateTime:                    
    reference:                       www.geos-chem.org; wiki.geos-chem.org
    ...                              ...
    simulation_end_date_and_time:    2019-01-01 00:00:00z
    regrid_method:                   conservative
    stretch_factor:                  1.0
    target_longitude:                170.0
    target_latitude:                 -90.0
    cs_res:                          48`

The information of ./GC-Classic/GEOSChem.Restart.TransportTracers.20190101_0000z.nc4 is as follows:
GEOSChem.Restart.TransportTracers.20190101_0000z.nc4.log

The information of GCHP.Restart.TransportTracers.20190101_0000z.c48.nc4 is as follows:
GCHP.Restart.TransportTracers.20190101_0000z.c48.nc4.log

@lizziel
Copy link
Contributor

lizziel commented Sep 8, 2023

Thanks @helpyuan. I'll try it on my end and see what I can figure out. There may be a bug.

@lizziel lizziel assigned lizziel and unassigned yantosca Sep 8, 2023
@lizziel
Copy link
Contributor

lizziel commented Sep 28, 2023

Hi @helpyuan, this issue is being looked at by @yantosca. He is finding several problems with the GCPy regridding for generating a GCHP restart file from GC-Classic. I suggest not using the tool until a new version is released with the fixes.

@helpyuan
Copy link
Author

helpyuan commented Oct 6, 2023

Thanks for the heads up @lizziel!

@yantosca
Copy link
Contributor

yantosca commented Oct 6, 2023

@helpyuan: for details see PR #266.

@helpyuan
Copy link
Author

helpyuan commented Oct 7, 2023

Thanks @yantosca.

@yantosca
Copy link
Contributor

Thanks @yantosca and @lizziel.

I have been able to regrid LL to CS, but the output does not include the variable "lon".

This is now fixed with PR #263 having been merged into the dev branch.

@helpyuan
Copy link
Author

That's great @yantosca!

Copy link
Contributor

I think we can close out this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Question A question submitted by a user topic: Regridding Issues pertaining to horizontal & vertical regridding topic: User Environment Relating to python and/or conda environment
Projects
None yet
3 participants