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

delete cgll2latlonz function #958

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/src/regridder.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ ClimaCoupler.Regridder.remap_field_cgll_to_rll
ClimaCoupler.Regridder.land_fraction
ClimaCoupler.Regridder.update_surface_fractions!
ClimaCoupler.Regridder.combine_surfaces!
ClimaCoupler.Regridder.cgll2latlonz
ClimaCoupler.Regridder.combine_surfaces_from_sol!
```

Expand All @@ -33,4 +32,4 @@ ClimaCoupler.Regridder.binary_mask
ClimaCoupler.Regridder.read_remapped_field
ClimaCoupler.Regridder.get_coords
ClimaCoupler.Regridder.get_time
```
```
26 changes: 0 additions & 26 deletions src/Regridder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export write_to_hdf5,
combine_surfaces_from_sol!,
binary_mask,
nans_to_zero,
cgll2latlonz,
truncate_dataset


Expand Down Expand Up @@ -612,31 +611,6 @@ function read_remapped_field(name::Symbol, datafile_latlon::String, lev_name = "
return out
end


"""
function cgll2latlonz(field; DIR = "cgll2latlonz_dir", nlat = 360, nlon = 720, clean_dir = true)

Regrids a field from CGLL to an RLL array using TempestRemap. It can hanlde multiple other dimensions, such as time and level.

# Arguments
- `field`: [CC.Fields.Field] to be remapped.
- `DIR`: [String] directory used for remapping.
- `nlat`: [Int] number of latitudes of the regridded array.
- `nlon`: [Int] number of longitudes of the regridded array.
- `clean_dir`: [Bool] flag to delete the temporary directory after remapping.

# Returns
- Tuple containing the remapped field and its coordinates.
"""
function cgll2latlonz(field; DIR = "cgll2latlonz_dir", nlat = 360, nlon = 720, clean_dir = true)
isdir(DIR) ? nothing : mkpath(DIR)
datafile_latlon = DIR * "/remapped_" * string(Interfacer.name) * ".nc"
remap_field_cgll_to_rll(:var, field, DIR, datafile_latlon, nlat = nlat, nlon = nlon)
new_data, coords = read_remapped_field(:var, datafile_latlon)
clean_dir && rm(DIR; recursive = true)
return new_data, coords
end

"""
truncate_dataset(datafile, filename, varname, datapath_trunc, date0, t_start, t_end, comms_ctx)

Expand Down
6 changes: 5 additions & 1 deletion test/regridder_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ for FT in (Float32, Float64)
Base.close(hdfreader)

# regrid back to lat-lon
T_rll, _ = Regridder.cgll2latlonz(T_cgll)
datafile_latlon = joinpath(REGRID_DIR, "remapped_latlon.nc")
nlat = 360
nlon = 720
Regridder.remap_field_cgll_to_rll(:var, T_cgll, REGRID_DIR, datafile_latlon, nlat = nlat, nlon = nlon)
T_rll, _ = Regridder.read_remapped_field(:var, datafile_latlon)

# check consistency across z-levels
@test T_rll[:, :, 1] == T_rll[:, :, 2]
Expand Down
Loading