This repository has been archived by the owner on Apr 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
esmlab.resample with freq='mon' yields unexpected results when called with monthly data #135
Labels
bug
Something isn't working
Comments
Incidentally, calling In [6]: ds = esmlab.datasets.open_dataset(
'cmip6_fgco2_Omon_CESM2_1pctCO2_r1i1p1f1_gn_000101-005012',
decode_times=True).resample({'time': '1Y'}).nearest()
In [7]: ds
Out[7]:
<xarray.Dataset>
Dimensions: (d2: 2, nlat: 384, nlon: 320, time: 2, vertices: 4)
Coordinates:
* time (time) object 0001-12-31 00:00:00 0002-12-31 00:00:00
lat (nlat, nlon) float64 -79.22 -79.22 -79.22 ... 72.2 72.19 72.19
lon (nlat, nlon) float64 320.6 321.7 322.8 ... 318.9 319.4 319.8
* nlat (nlat) int32 1 2 3 4 5 6 7 8 ... 377 378 379 380 381 382 383 384
* nlon (nlon) int32 1 2 3 4 5 6 7 8 ... 313 314 315 316 317 318 319 320
Dimensions without coordinates: d2, vertices
Data variables:
fgco2 (time, nlat, nlon) float32 ...
time_bnds (time, d2) object ...
lat_bnds (nlat, nlon, vertices) float32 -79.48714 -79.48714 ... 72.41355
lon_bnds (nlat, nlon, vertices) float32 320.0 321.125 ... 320.0 319.586
Attributes:
Conventions: CF-1.7 CMIP-6.2
activity_id: CMIP
branch_method: standard
branch_time_in_child: 0.0
branch_time_in_parent: 182500.0
case_id: 58
cesm_casename: b.e21.B1PCT.f09_g17.CMIP6-1pctCO2.001
contact: cesm_cmip6@ucar.edu
creation_date: 2019-03-09T17:23:49Z
data_specs_version: 01.00.29
experiment: 1 percent per year increase in CO2
experiment_id: 1pctCO2
external_variables: areacello
forcing_index: 1
frequency: mon
further_info_url: https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.1...
grid: native gx1v7 displaced pole grid (384x320 latxlon)
grid_label: gn
initialization_index: 1
institution: National Center for Atmospheric Research, Climate...
institution_id: NCAR
license: CMIP6 model data produced by <The National Center...
mip_era: CMIP6
model_doi_url: https://doi.org/10.5065/D67H1H0V
nominal_resolution: 100 km
parent_activity_id: CMIP
parent_experiment_id: piControl
parent_mip_era: CMIP6
parent_source_id: CESM2
parent_time_units: days since 0001-01-01 00:00:00
parent_variant_label: r1i1p1f1
physics_index: 1
product: model-output
realization_index: 1
realm: ocnBgchem
source: CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite v...
source_id: CESM2
source_type: AOGCM BGC AER
sub_experiment: none
sub_experiment_id: none
table_id: Omon
tracking_id: hdl:21.14100/1ccc0d3e-97b1-4392-b607-e037670617ef
variable_id: fgco2
variant_info: CMIP6 CESM2 1pctCO2 experiment with interactive a...
variant_label: r1i1p1f1
In [8]: esmlab.resample(ds, freq='ann')
/Users/abanihi/opt/miniconda3/envs/devel/lib/python3.6/site-packages/xarray/core/nanops.py:159: RuntimeWarning: Mean of empty slice
return np.nanmean(a, axis=axis, dtype=dtype)
Out[8]:
<xarray.Dataset>
Dimensions: (d2: 2, nlat: 384, nlon: 320, time: 1, vertices: 4)
Coordinates:
* nlat (nlat) int64 1 2 3 4 5 6 7 8 ... 377 378 379 380 381 382 383 384
* nlon (nlon) int64 1 2 3 4 5 6 7 8 ... 313 314 315 316 317 318 319 320
* time (time) object 0002-07-02 12:00:00
lat (nlat, nlon) float64 -79.22 -79.22 -79.22 ... 72.2 72.19 72.19
lon (nlat, nlon) float64 320.6 321.7 322.8 ... 318.9 319.4 319.8
Dimensions without coordinates: d2, vertices
Data variables:
fgco2 (time, nlat, nlon) float64 nan nan nan nan ... nan nan nan nan
time_bnds (d2, time) object 0002-01-01 00:00:00 0003-01-01 00:00:00
lat_bnds (nlat, nlon, vertices) float32 -79.48714 -79.48714 ... 72.41355
lon_bnds (nlat, nlon, vertices) float32 320.0 321.125 ... 320.0 319.586
Attributes:
history: \n2019-06-09 11:31:50.773175 esmlab.resample(<DATASET>, freq="a... |
@matt-long, I am currently trying to fix this issue and I am wondering whether we didn't complicate our current implementations for Could you help me understand whether I am missing anything by assuming that the following (with additional steps to handle weights, etc..) would fix our issues? Let's say you have the following dataset: In [14]: ds = esmlab.datasets.open_dataset(
'cmip6_fgco2_Omon_CESM2_1pctCO2_r1i1p1f1_gn_000101-005012',
decode_times=True).resample({'time': '7D'}).nearest()
In [15]: ds
Out[15]:
<xarray.Dataset>
Dimensions: (d2: 2, nlat: 384, nlon: 320, time: 100, vertices: 4)
Coordinates:
* time (time) object 0001-01-15 00:00:00 ... 0002-12-09 00:00:00
lat (nlat, nlon) float64 -79.22 -79.22 -79.22 ... 72.2 72.19 72.19
lon (nlat, nlon) float64 320.6 321.7 322.8 ... 318.9 319.4 319.8
* nlat (nlat) int32 1 2 3 4 5 6 7 8 ... 377 378 379 380 381 382 383 384
* nlon (nlon) int32 1 2 3 4 5 6 7 8 ... 313 314 315 316 317 318 319 320
Dimensions without coordinates: d2, vertices
Data variables:
fgco2 (time, nlat, nlon) float32 ...
time_bnds (time, d2) object ...
lat_bnds (nlat, nlon, vertices) float32 -79.48714 -79.48714 ... 72.41355
lon_bnds (nlat, nlon, vertices) float32 320.0 321.125 ... 320.0 319.586
Attributes:
Conventions: CF-1.7 CMIP-6.2
activity_id: CMIP
branch_method: standard
branch_time_in_child: 0.0
branch_time_in_parent: 182500.0
case_id: 58
cesm_casename: b.e21.B1PCT.f09_g17.CMIP6-1pctCO2.001
contact: cesm_cmip6@ucar.edu
creation_date: 2019-03-09T17:23:49Z
data_specs_version: 01.00.29
experiment: 1 percent per year increase in CO2
experiment_id: 1pctCO2
external_variables: areacello
forcing_index: 1
frequency: mon
further_info_url: https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.1...
grid: native gx1v7 displaced pole grid (384x320 latxlon)
grid_label: gn
initialization_index: 1
institution: National Center for Atmospheric Research, Climate...
institution_id: NCAR
license: CMIP6 model data produced by <The National Center...
mip_era: CMIP6
model_doi_url: https://doi.org/10.5065/D67H1H0V
nominal_resolution: 100 km
parent_activity_id: CMIP
parent_experiment_id: piControl
parent_mip_era: CMIP6
parent_source_id: CESM2
parent_time_units: days since 0001-01-01 00:00:00
parent_variant_label: r1i1p1f1
physics_index: 1
product: model-output
realization_index: 1
realm: ocnBgchem
source: CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite v...
source_id: CESM2
source_type: AOGCM BGC AER
sub_experiment: none
sub_experiment_id: none
table_id: Omon
tracking_id: hdl:21.14100/1ccc0d3e-97b1-4392-b607-e037670617ef
variable_id: fgco2
variant_info: CMIP6 CESM2 1pctCO2 experiment with interactive a...
variant_label: r1i1p1f1
In [16]: ds_mon = ds.resample({'time': '1M'}).interpolate('nearest')
/Users/abanihi/opt/miniconda3/envs/devel/lib/python3.6/site-packages/xarray/core/nanops.py:159: RuntimeWarning: Mean of empty slice
return np.nanmean(a, axis=axis, dtype=dtype)
In [17]: ds_mon
Out[17]:
<xarray.Dataset>
Dimensions: (nlat: 384, nlon: 320, time: 24, vertices: 4)
Coordinates:
* time (time) object 0001-01-31 00:00:00 ... 0002-12-31 00:00:00
lat (nlat, nlon) float64 -79.22 -79.22 -79.22 ... 72.2 72.19 72.19
lon (nlat, nlon) float64 320.6 321.7 322.8 323.9 ... 318.9 319.4 319.8
* nlat (nlat) int32 1 2 3 4 5 6 7 8 9 ... 377 378 379 380 381 382 383 384
* nlon (nlon) int32 1 2 3 4 5 6 7 8 9 ... 313 314 315 316 317 318 319 320
Dimensions without coordinates: vertices
Data variables:
fgco2 (time, nlat, nlon) float32 nan nan nan nan nan ... nan nan nan nan
lat_bnds (time, nlat, nlon, vertices) float32 -79.48714 ... 72.41355
lon_bnds (time, nlat, nlon, vertices) float32 320.0 321.125 ... 319.586
Attributes:
Conventions: CF-1.7 CMIP-6.2
activity_id: CMIP
branch_method: standard
branch_time_in_child: 0.0
branch_time_in_parent: 182500.0
case_id: 58
cesm_casename: b.e21.B1PCT.f09_g17.CMIP6-1pctCO2.001
contact: cesm_cmip6@ucar.edu
creation_date: 2019-03-09T17:23:49Z
data_specs_version: 01.00.29
experiment: 1 percent per year increase in CO2
experiment_id: 1pctCO2
external_variables: areacello
forcing_index: 1
frequency: mon
further_info_url: https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.1...
grid: native gx1v7 displaced pole grid (384x320 latxlon)
grid_label: gn
initialization_index: 1
institution: National Center for Atmospheric Research, Climate...
institution_id: NCAR
license: CMIP6 model data produced by <The National Center...
mip_era: CMIP6
model_doi_url: https://doi.org/10.5065/D67H1H0V
nominal_resolution: 100 km
parent_activity_id: CMIP
parent_experiment_id: piControl
parent_mip_era: CMIP6
parent_source_id: CESM2
parent_time_units: days since 0001-01-01 00:00:00
parent_variant_label: r1i1p1f1
physics_index: 1
product: model-output
realization_index: 1
realm: ocnBgchem
source: CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite v...
source_id: CESM2
source_type: AOGCM BGC AER
sub_experiment: none
sub_experiment_id: none
table_id: Omon
tracking_id: hdl:21.14100/1ccc0d3e-97b1-4392-b607-e037670617ef
variable_id: fgco2
variant_info: CMIP6 CESM2 1pctCO2 experiment with interactive a...
variant_label: r1i1p1f1
In [18]: ds_ann = ds.resample({'time': '1Y'}).interpolate('nearest')
/Users/abanihi/opt/miniconda3/envs/devel/lib/python3.6/site-packages/xarray/core/nanops.py:159: RuntimeWarning: Mean of empty slice
return np.nanmean(a, axis=axis, dtype=dtype)
In [19]: ds_ann
Out[19]:
<xarray.Dataset>
Dimensions: (nlat: 384, nlon: 320, time: 2, vertices: 4)
Coordinates:
* time (time) object 0001-12-31 00:00:00 0002-12-31 00:00:00
lat (nlat, nlon) float64 -79.22 -79.22 -79.22 ... 72.2 72.19 72.19
lon (nlat, nlon) float64 320.6 321.7 322.8 323.9 ... 318.9 319.4 319.8
* nlat (nlat) int32 1 2 3 4 5 6 7 8 9 ... 377 378 379 380 381 382 383 384
* nlon (nlon) int32 1 2 3 4 5 6 7 8 9 ... 313 314 315 316 317 318 319 320
Dimensions without coordinates: vertices
Data variables:
fgco2 (time, nlat, nlon) float32 nan nan nan nan nan ... nan nan nan nan
lat_bnds (time, nlat, nlon, vertices) float32 -79.48714 ... 72.41355
lon_bnds (time, nlat, nlon, vertices) float32 320.0 321.125 ... 319.586
Attributes:
Conventions: CF-1.7 CMIP-6.2
activity_id: CMIP
branch_method: standard
branch_time_in_child: 0.0
branch_time_in_parent: 182500.0
case_id: 58
cesm_casename: b.e21.B1PCT.f09_g17.CMIP6-1pctCO2.001
contact: cesm_cmip6@ucar.edu
creation_date: 2019-03-09T17:23:49Z
data_specs_version: 01.00.29
experiment: 1 percent per year increase in CO2
experiment_id: 1pctCO2
external_variables: areacello
forcing_index: 1
frequency: mon
further_info_url: https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.1...
grid: native gx1v7 displaced pole grid (384x320 latxlon)
grid_label: gn
initialization_index: 1
institution: National Center for Atmospheric Research, Climate...
institution_id: NCAR
license: CMIP6 model data produced by <The National Center...
mip_era: CMIP6
model_doi_url: https://doi.org/10.5065/D67H1H0V
nominal_resolution: 100 km
parent_activity_id: CMIP
parent_experiment_id: piControl
parent_mip_era: CMIP6
parent_source_id: CESM2
parent_time_units: days since 0001-01-01 00:00:00
parent_variant_label: r1i1p1f1
physics_index: 1
product: model-output
realization_index: 1
realm: ocnBgchem
source: CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite v...
source_id: CESM2
source_type: AOGCM BGC AER
sub_experiment: none
sub_experiment_id: none
table_id: Omon
tracking_id: hdl:21.14100/1ccc0d3e-97b1-4392-b607-e037670617ef
variable_id: fgco2
variant_info: CMIP6 CESM2 1pctCO2 experiment with interactive a...
variant_label: r1i1p1f1 Also, wouldn't this completely fix #55 ?? Comments would be helpful from @kmpaul , @jukent , @alperaltuntas, @klindsay28 and any others. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Calling:
where dset() is already monthly resolution
Expected:To do nothing. However, it returns a dataset with mucked up time axis and 12 not 24 values!
Minimal Example:
The text was updated successfully, but these errors were encountered: