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

Mean clim unified workflow #1126

Draft
wants to merge 62 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
eb12696
clean up, simplify, modernize the code
lee1043 Aug 12, 2024
ad9fa8e
bug fix
lee1043 Aug 12, 2024
db1270b
include period in the output file name as default
lee1043 Aug 12, 2024
fdd44b4
initial commit
lee1043 Sep 11, 2024
37658b0
clean up
lee1043 Sep 11, 2024
8f86abd
clean up
lee1043 Sep 11, 2024
ffa4f7d
clean up
lee1043 Sep 11, 2024
709b7e2
clean up
lee1043 Sep 11, 2024
42e3de8
clean up
lee1043 Sep 11, 2024
8d5af54
clean up
lee1043 Sep 11, 2024
2c0a5fe
clean up
lee1043 Sep 11, 2024
44dc275
clean up
lee1043 Sep 11, 2024
461d34f
clean up, bug fix
lee1043 Sep 11, 2024
ebc04d0
clean up
lee1043 Sep 12, 2024
ee16b19
clean up
lee1043 Sep 12, 2024
dd40546
clean up
lee1043 Sep 12, 2024
66bc090
clean up
lee1043 Sep 12, 2024
2754fd5
clean up
lee1043 Sep 12, 2024
7a85967
in progress
lee1043 Sep 15, 2024
3d76aa3
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Sep 15, 2024
d28c5d2
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Sep 17, 2024
9ebd5b9
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Sep 23, 2024
be1d12b
add dates comparing function
lee1043 Sep 23, 2024
0b5f6a3
compare given dates to actual dataset to find overlapping period
lee1043 Sep 23, 2024
22643f9
in progress. commit made for safe backup
lee1043 Sep 23, 2024
499ebd0
add new function: get_calendar
lee1043 Sep 23, 2024
cf39a4b
add new function: regenerate_time_axis
lee1043 Sep 23, 2024
1623c18
regenerate time axis of data if needed
lee1043 Sep 23, 2024
d530f95
clean up
lee1043 Sep 23, 2024
63e1ec6
in progress
lee1043 Sep 23, 2024
395f3db
in progress
lee1043 Sep 23, 2024
7eeef6f
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Sep 24, 2024
5f776c1
add new func
lee1043 Sep 24, 2024
a82eb95
Merge branch 'mean_clim_upgrade_lee1043_20240812' of github.com:PCMDI…
lee1043 Sep 24, 2024
0c881c8
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Sep 24, 2024
4fe0088
Merge branch 'mean_clim_upgrade_lee1043_20240812' of github.com:PCMDI…
lee1043 Sep 24, 2024
63eb9d6
in progress ... commit for back up the latest
lee1043 Sep 25, 2024
4c9d915
make extract_level function by reusing original code part from mean c…
lee1043 Sep 26, 2024
d1ca557
in progress. commit made for save progress as back up
lee1043 Sep 26, 2024
13dc5a6
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Sep 26, 2024
378ee88
in progress
lee1043 Sep 26, 2024
3dfcd87
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Sep 27, 2024
8a849f9
Merge branch 'mean_clim_upgrade_lee1043_20240812' of github.com:PCMDI…
lee1043 Sep 27, 2024
5294518
pre-commit fix
lee1043 Sep 27, 2024
3546f0e
consider cases that plev does not have units attrs
lee1043 Sep 27, 2024
862929b
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Sep 27, 2024
c7d003a
more sanity checks to make workflow to be more robust
lee1043 Sep 30, 2024
2445555
clean up
lee1043 Sep 30, 2024
c1e90b3
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Oct 4, 2024
23c253d
clean up, bug fix, in progress
lee1043 Oct 5, 2024
ee27995
bypass regridding if grids of current and target are identical
lee1043 Oct 8, 2024
0587008
bug fix, clean up, in progress
lee1043 Oct 8, 2024
8ea90c4
in progress
lee1043 Oct 8, 2024
cc7d7e0
bug fix
lee1043 Oct 8, 2024
c80a957
in progress
lee1043 Oct 8, 2024
7d76730
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Oct 24, 2024
e189fc0
clean up
lee1043 Nov 12, 2024
e98b0d2
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Nov 18, 2024
4fbfe1a
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Nov 19, 2024
fddcdc5
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Nov 26, 2024
60c2254
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Nov 26, 2024
a8df2a7
Merge branch 'main' into mean_clim_upgrade_lee1043_20240812
lee1043 Nov 28, 2024
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
39 changes: 39 additions & 0 deletions pcmdi_metrics/io/xcdat_dataset_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,45 @@ def get_grid(
return d[[lat_key, lon_key, lat_bnds_key, lon_bnds_key]]


def get_grid_shape(
d: Union[xr.Dataset, xr.DataArray],
) -> tuple:
"""
Get the shape of the grid in terms of longitude and latitude dimensions.

Parameters
----------
d : Union[xr.Dataset, xr.DataArray]
Input xarray dataset or data array containing longitude and latitude dimensions.

Returns
-------
tuple
A tuple representing the size of the longitude and latitude dimensions
in the form (longitude_size, latitude_size).

Notes
-----
The function retrieves the keys for longitude and latitude using the
`get_longitude_key` and `get_latitude_key` functions, then uses these keys to
obtain the sizes of the respective dimensions.

Examples
--------
>>> ds = xr.Dataset(...)
>>> get_grid_shape(ds)
(180, 90)

See Also
--------
get_longitude_key, get_latitude_key
"""
lon_key = get_longitude_key(d)
lat_key = get_latitude_key(d)

return tuple(d.sizes[dim] for dim in [lon_key, lat_key])


def get_calendar(d: Union[xr.Dataset, xr.DataArray]) -> str:
"""
Get the calendar type from an xarray Dataset or DataArray.
Expand Down
Loading
Loading