diff --git a/.gitignore b/.gitignore index f0427f5..2deebe0 100644 --- a/.gitignore +++ b/.gitignore @@ -104,7 +104,6 @@ docs/source/output-sanitize.cfg # External Sources #src/external -src/ # Django stuff: local_settings.py diff --git a/notebooks/decadal_calendar_fix.ipynb b/notebooks/decadal_calendar_fix.ipynb index 37c3f37..f006323 100644 --- a/notebooks/decadal_calendar_fix.ipynb +++ b/notebooks/decadal_calendar_fix.ipynb @@ -10,522 +10,162 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 9, "id": "06856aa1-30cb-4edd-a461-b1a08fde8ec5", "metadata": {}, "outputs": [], "source": [ - "import xarray as xr" + "import xarray as xr\n", + "from rook.utils.decadal_fixes import apply_decadal_fixes, decadal_fix_calendar\n", + "from roocs_utils.xarray_utils.xarray_utils import open_xr_dataset\n", + "from rooki import rooki\n", + "\n", + "import tempfile" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "b1ecf482-c9a6-46ab-9485-6a022756d16f", + "metadata": {}, + "outputs": [], + "source": [ + "tmp_dir = tempfile.TemporaryDirectory(dir=None)\n", + "tmp_dir.cleanup()" ] }, { "cell_type": "code", "execution_count": 2, - "id": "c696b650-d309-4337-9c0e-b6285fb318bf", + "id": "a6019f44-1ea8-4f99-b9b4-6a13cf4f765d", + "metadata": {}, + "outputs": [], + "source": [ + "ds_id = \"c3s-cmip6-decadal.DCPP.EC-Earth-Consortium.EC-Earth3.dcppA-hindcast.s1976-r3i1p1f1.Amon.psl.gr.v20201215\"\n" + ] + }, + { + "cell_type": "markdown", + "id": "eb0a6e43-a9bd-43a3-b10a-598143042dbd", + "metadata": {}, + "source": [ + "## ds with mixed gregorian and proleptic gregorian\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "5462716e-7b3c-4b0b-bfad-34eb3c134434", "metadata": {}, "outputs": [ { "data": { - "text/html": [ - "
<xarray.Dataset>\n", - "Dimensions: (time: 2, realization: 10, bnds: 2, lat: 256, lon: 512)\n", - "Coordinates:\n", - " * time (time) datetime64[ns] 2020-11-16 2020-12-16T12:00:00\n", - " * lat (lat) float64 -89.46 -88.77 -88.07 -87.37 ... 88.07 88.77 89.46\n", - " * lon (lon) float64 0.3516 1.055 1.758 2.461 ... 358.2 358.9 359.6\n", - " reftime datetime64[ns] ...\n", - " leadtime (time) timedelta64[ns] ...\n", - " * realization (realization) int32 10 1 2 3 4 5 6 7 8 9\n", - "Dimensions without coordinates: bnds\n", - "Data variables:\n", - " time_bnds (realization, time, bnds) datetime64[ns] ...\n", - " lat_bnds (realization, time, lat, bnds) float64 ...\n", - " lon_bnds (realization, time, lon, bnds) float64 ...\n", - " psl (realization, time, lat, lon) float32 ...\n", - "Attributes: (12/52)\n", - " Conventions: CF-1.7 CMIP-6.2\n", - " activity_id: DCPP\n", - " branch_method: no parent\n", - " branch_time: 0.0\n", - " branch_time_in_child: 0.0\n", - " branch_time_in_parent: 0.0\n", - " ... ...\n", - " license: CMIP6 model data produced by EC-Earth-Consor...\n", - " cmor_version: 3.4.0\n", - " forcing_description: f1, CMIP6 historical forcings\n", - " physics_description: physics from the standard model configuratio...\n", - " initialization_description: Atmosphere initialization based on full-fiel...\n", - " startdate: s202011
<xarray.Dataset>\n", - "Dimensions: (time: 2, realization: 10, bnds: 2, lat: 256, lon: 512)\n", + "Dimensions: (time: 24, bnds: 2, lat: 256, lon: 512)\n", "Coordinates:\n", - " * time (time) datetime64[ns] 2020-11-16 2020-12-16T12:00:00\n", + " * time (time) object 1984-11-16 00:00:00 ... 1986-10-16 12:00:00\n", " * lat (lat) float64 -89.46 -88.77 -88.07 -87.37 ... 88.07 88.77 89.46\n", - " * lon (lon) float64 0.3516 1.055 1.758 2.461 ... 358.2 358.9 359.6\n", - " reftime datetime64[ns] ...\n", - " leadtime (time) timedelta64[ns] ...\n", - " * realization (realization) int32 10 1 2 3 4 5 6 7 8 9\n", + " * lon (lon) float64 0.0 0.7031 1.406 2.109 ... 357.9 358.6 359.3\n", + " reftime datetime64[ns] 1976-11-01\n", + " leadtime (time) float64 2.937e+03 2.967e+03 ... 3.606e+03 3.636e+03\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", - " time_bnds (realization, time, bnds) datetime64[ns] ...\n", - " lat_bnds (realization, time, lat, bnds) float64 ...\n", - " lon_bnds (realization, time, lon, bnds) float64 ...\n", - " psl (realization, time, lat, lon) float32 ...\n", + " time_bnds (time, bnds) object 1984-11-01 00:00:00 ... 1986-11-01 00:00:00\n", + " lat_bnds (time, lat, bnds) float64 -90.0 -89.11 -89.11 ... 89.11 90.0\n", + " lon_bnds (time, lon, bnds) float64 -0.3516 0.3516 0.3516 ... 358.9 359.6\n", + " psl (time, lat, lon) float32 9.994e+04 9.994e+04 ... 1.014e+05\n", + " realization int32 3\n", "Attributes: (12/52)\n", " Conventions: CF-1.7 CMIP-6.2\n", " activity_id: DCPP\n", @@ -917,25 +557,217 @@ " branch_time_in_child: 0.0\n", " branch_time_in_parent: 0.0\n", " ... ...\n", - " license: CMIP6 model data produced by EC-Earth-Consor...\n", - " cmor_version: 3.4.0\n", + " nominal_resolution: 100 km\n", + " sub_experiment: initialized near end of year 1976\n", " forcing_description: f1, CMIP6 historical forcings\n", " physics_description: physics from the standard model configuratio...\n", " initialization_description: Atmosphere initialization based on full-fiel...\n", - " startdate: s202011" ], "text/plain": [ "