Skip to content

Conversation

kilicomu
Copy link
Contributor

@kilicomu kilicomu commented Jan 6, 2023

This PR contains a first go at reworking the regrid_restart_file GCPy module to correctly function with GCHP v14.

Key changes are:

  • Adds stretched-grid options to the main entry point:
    • --stretched-grid - whether or not we are regridding to a stretched-grid
    • --stretch-factor - the stretch factor of the target grid, which will be added to the global attributes of the output file as STRETCH_FACTOR
    • --target-latitude - the target latitude of the output stretched-grid, which will be added to the global attributes of the output file as TARGET_LAT
    • --target-longitude - the target longitude of the output stretched-grid, which will be added to the global attributes of the output file as TARGET_LON
    • If --stretched-grid is detected, the program requires all three other stretched-grid options to be passed
  • Reworks command-line argument and option parsing:
    • Now uses argparse instead of directly reading sys.argv
    • Includes description, example usage, and help text for the program
  • Adds documentation throughout the module

I've re-tested the tool with the following regridding configurations:

  • Resizing a C90 grid to C48
  • Stretching a C48 grid to C120 with SF 6.0
  • Re-stretching a C120 grid with SF 6.0 grid to a C48 grid with SF 2.0
    and unless I've missed something (not unlikely - please check!), it looks ok and GCHP 14.0.2 will run fine with the results.

I don't think this is the final solution for regridding in GCPy, though. This still requires gridspec-create => ESMF_RegridWeightGen => python -m gcpy.regrid_restart_file ... as opposed to just using the GCPy module, which would be ideal. I think it is possible to wrap up the gridspec and ESMF_RegridWeightGen stuff into the module so there is just a single task for users to complete, but I don't have time right now to properly look at it.

Let me know what you think.

@Jourdan-He
Copy link
Contributor

Thanks @kilicomu , I have created a draft PR that integrated gridspec-create and ESMF_RegridWeightGen into one step using pre_regrid.sh here: #198.

@Jourdan-He
Copy link
Contributor

Hi @kilicomu , I've tried regridding files using your updated regrid_restart_file.py. I've tested regridding C24 to C90, C24 to C48, C24 to C120 with SF 4.0, C48 to C90 with SF 4.0, and all of them worked. I tried to run GCHP v14.0.2 with regridded C90 and C120 restart file. After consulting from @lizziel , there is likely a system error on my server that causes both simulations to hang, but restart files have been read in without errors before the hanging point.

@lizziel
Copy link
Contributor

lizziel commented Feb 8, 2023

Has anyone tested it with lat-lon to cubed sphere? We want to retire CSGrid for the regridding of GEOS-Chem Classic restart files for use in GCHP.

@lizziel
Copy link
Contributor

lizziel commented Feb 8, 2023

Also, no worries if not. I wouldn't let it to hold up fixing the regridding capability for stretched grid asap.

@kilicomu
Copy link
Contributor Author

kilicomu commented Feb 9, 2023

@lizziel If it worked for lat-lon to gcs before, it should still do, but I will test today and let you know.

@kilicomu
Copy link
Contributor Author

@lizziel The script I have adapted didn't work for regridding lat-lon to gcs before, so it still doesn't. We can open an issue to get that implemented, but I'd like to get this merged in so that we can get on with the stretched grid in GCHP - hope that's ok!

@Jourdan-He If you're happy with the changes to the script, we can merge them and I'll get on with the documentation.

@Jourdan-He
Copy link
Contributor

@kilicomu Sure, we can merge them

@Jourdan-He Jourdan-He merged commit a010633 into geoschem:dev Feb 15, 2023
@yantosca yantosca added this to the 1.3.3 milestone May 23, 2023
hannahnesser pushed a commit to hannahnesser/gcpy that referenced this pull request Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants