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

Remove regridding funcs that are in ClimaUtilities #1109

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

imreddyTeja
Copy link
Contributor

@imreddyTeja imreddyTeja commented Dec 5, 2024

Closes #1107 and Closes #425
Regridder module removed. The hdwrite_regridfile_rll_to_cgll only works for 2d spaces in ClimaUtilities, and the function in Regridder.jl also worked for 3d spaced, so this functionality is lost.

The functions read_available_dates and yyyymmmddd_to_datetime are copied from ClimaUtilities. This is necessary because land_fraction needs the first date in the dataset. TempestRegridder calls hdwrite_regridfile_rll_to_cgll, which extracts the dates and returns them, but TempestRegridder then discards those extracted dates.

The regridder functions in ClimaUtilities do not work properly when the time dim is made up of numbers, and it errors when the time dim is made up of large floats. To function properly, the time time must be datetimes. The functions in Regridder.jl worked with the time dim as numbers.

Many of the regridding functions in Regridder.jl allowed the outfile_root to be set. When using the TempestRegridder, it is autmatically set to the varname. This results in file with names structured like: "varname_varname_time.hdf5"

Purpose

To-do

  • move Regridder module docs to news.md
  • make changes in ClimaUtilities (time reading, outfile_root, varname to varnames)
    see here
    changes to the time reading probably require a small discussion, and making TempestRegridder support multiple varnames requires enough changes to be a separate issue (implementing would change interface, or would need to continue supporting old interface)
  • Docs differentiate internal vs external functions
  • test for binary mask

Content

  • Regridder module removed (also checked that there is equivalent functionality in ClimaUtilities. If there was not, it is noted)
  • added to NEWS.md

  • I have read and checked the items on the review checklist.

@imreddyTeja imreddyTeja force-pushed the tr/use-ClimaUtilities.Regridders branch 7 times, most recently from 9432748 to 266da3f Compare December 11, 2024 20:16
@imreddyTeja imreddyTeja marked this pull request as ready for review December 12, 2024 18:15
## FieldExchanger Internal Functions

```@docs
ClimaCoupler.FieldExchanger.combine_surfaces!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nans_to_zero is also an internal function here now

Copy link
Member

@juliasloan25 juliasloan25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you Teja! I just left a few small comments

- `target`: [CC.Fields.Field] destination of remapping.
- `source`: [CC.Fields.Field] source of remapping.
"""
function dummmy_remap!(target, source)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a small style choice, but it's good practice to put internal functions at the end of a file, so if a user looks into the file to find a function they're using they can find it more easily.

@@ -118,13 +119,41 @@ function gen_ncdata_time(FT, path, varname, val)
# Define variables
lon = NCDatasets.defVar(nc, "lon", FT, ("lon",))
lat = NCDatasets.defVar(nc, "lat", FT, ("lat",))
time = NCDatasets.defVar(nc, "time", Float64, ("time",))
time = NCDatasets.defVar(nc, "time", Dates.DateTime.([2020.0, 2021.0]), ("time",))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this change needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like gen_ncdata_time and gen_ncdata_date were only used in the regridder tests so now they're unused and can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That change was made because the read_available_dates in ClimaUtilities incorrectly interprets the time dimension when it is a Number. The unused gen_ncdata_time and gen_ncdata_date are now removed.

Comment on lines 65 to 68
Interfacer.get_field(::TestSurfaceSimulationA, ::Val{:random}) = 1.0
Interfacer.get_field(::TestSurfaceSimulationB, ::Val{:random}) = 1.0
Interfacer.get_field(::TestSurfaceSimulationC, ::Val{:random}) = 1.0
Interfacer.get_field(::TestSurfaceSimulationD, ::Val{:random}) = 1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good for some of these values to be not 1 (like you have for the area_fraction functions below)

@juliasloan25
Copy link
Member

It will be good to make the ClimaUtilities TempestRegridder changes we talked about too, but I'm okay with those going in after this is merged :)

@imreddyTeja imreddyTeja force-pushed the tr/use-ClimaUtilities.Regridders branch from 34c7381 to 7b76d0c Compare December 12, 2024 22:14
Remove all unused functions from Regridder module.
Used functions relocated to Utilities and FieldExchanger
modules. Docs and tests appropriately updated.

Re-add ClimaUtilities as dependancy after rebase

ClimaUtilities needs to be re-added after rebasing,
because it is now used for the ouput paths

Make suggested changes
The strdate_to_datetime and datetime_to_strdate are unused
after removing the Regridders module. Additionally, their funcitonality
is contained within the Dates package with Dates.format and
DateFormats.
@imreddyTeja imreddyTeja force-pushed the tr/use-ClimaUtilities.Regridders branch from 6f61bb7 to f5e7431 Compare December 17, 2024 18:36
@imreddyTeja imreddyTeja merged commit 8e89e82 into main Dec 19, 2024
11 checks passed
@imreddyTeja imreddyTeja deleted the tr/use-ClimaUtilities.Regridders branch December 19, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants