{ "cells": [ { "cell_type": "markdown", "id": "4342738c-1f6e-49cd-8142-583718a81095", "metadata": {}, "source": [ "# Error in CMIP6 subset operation with inconsistent lat_bnds (solved)\n", "\n", "* https://confluence.ecmwf.int/pages/viewpage.action?pageId=242064638\n", "* https://jira.ecmwf.int/plugins/servlet/desk/portal/1/CUS-20539\n", "\n", "See also:\n", "* https://github.com/roocs/clisops/issues/198\n", "* partial fix for FillValue: https://github.com/roocs/clisops/pull/204" ] }, { "cell_type": "code", "execution_count": 1, "id": "df2af37a-9b55-4893-b77b-e9fcacd07932", "metadata": {}, "outputs": [], "source": [ "import os\n", "os.environ['ROOK_URL'] = 'http://rook.dkrz.de/wps'\n", "#os.environ['ROOK_URL'] = 'http://compute.mips.copernicus-climate.eu/wps'\n", "#os.environ['ROOK_URL'] = 'http://rook3.cloud.dkrz.de/wps'\n", "\n", "from rooki import rooki" ] }, { "cell_type": "markdown", "id": "5a2755e7-78fb-41c2-8e33-71bf0251e4e0", "metadata": {}, "source": [ "## Get original file" ] }, { "cell_type": "code", "execution_count": 2, "id": "76ae3a89-1dbd-441b-823b-111747a49ddd", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "resp = rooki.subset(\n", " # collection=\"c3s-cmip6.CMIP.CSIRO-ARCCSS.ACCESS-CM2.historical.r1i1p1f1.day.tasmin.gn.v20191108\",\n", " collection=\"c3s-cmip6.CMIP.MPI-M.MPI-ESM1-2-HR.historical.r1i1p1f1.Amon.tasmin.gn.v20190710\",\n", " time='2010-01-01/2010-12-31',\n", " #area='58,-33,13,21'\n", " original_files=True,\n", ")\n", "resp.ok" ] }, { "cell_type": "code", "execution_count": 3, "id": "b2f9b92b-9719-4073-8500-716f96c099bd", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Downloading to /var/folders/qb/mg0csz190wd4rxybhhnwjln80000gn/T/metalink_3cjol36_/tasmin_Amon_MPI-ESM1-2-HR_historical_r1i1p1f1_gn_201001-201412.nc.\n" ] } ], "source": [ "ds = resp.datasets()[0]\n", "#ds" ] }, { "cell_type": "code", "execution_count": 4, "id": "195ced88-e9e8-463a-be76-0564a2703498", "metadata": {}, "outputs": [], "source": [ "# ds.info()" ] }, { "cell_type": "code", "execution_count": 5, "id": "5c065c0c-0a6d-49c4-94dd-dae25df7a95b", "metadata": {}, "outputs": [], "source": [ "# ds.tasmin.isel(time=0).plot()" ] }, { "cell_type": "code", "execution_count": 6, "id": "a9cca55a-e7dd-4d6f-acb1-d75ec5228976", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Downloading to /var/folders/qb/mg0csz190wd4rxybhhnwjln80000gn/T/metalink_3cjol36_/tasmin_Amon_MPI-ESM1-2-HR_historical_r1i1p1f1_gn_201001-201412.nc.\n" ] }, { "data": { "text/plain": [ "'/var/folders/qb/mg0csz190wd4rxybhhnwjln80000gn/T/metalink_3cjol36_/tasmin_Amon_MPI-ESM1-2-HR_historical_r1i1p1f1_gn_201001-201412.nc'" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "file = resp.download()[0]\n", "file" ] }, { "cell_type": "code", "execution_count": 7, "id": "0efe0a90-2030-4981-a0bf-f9fb473dd6a5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "netcdf tasmin_Amon_MPI-ESM1-2-HR_historical_r1i1p1f1_gn_201001-201412 {\n", "dimensions:\n", "\ttime = UNLIMITED ; // (60 currently)\n", "\tlat = 192 ;\n", "\tlon = 384 ;\n", "\tbnds = 2 ;\n", "variables:\n", "\tdouble time(time) ;\n", "\t\ttime:bounds = \"time_bnds\" ;\n", "\t\ttime:units = \"days since 1850-1-1 00:00:00\" ;\n", "\t\ttime:calendar = \"proleptic_gregorian\" ;\n", "\t\ttime:axis = \"T\" ;\n", "\t\ttime:long_name = \"time\" ;\n", "\t\ttime:standard_name = \"time\" ;\n", "\tdouble time_bnds(time, bnds) ;\n", "\tdouble lat(lat) ;\n", "\t\tlat:bounds = \"lat_bnds\" ;\n", "\t\tlat:units = \"degrees_north\" ;\n", "\t\tlat:axis = \"Y\" ;\n", "\t\tlat:long_name = \"Latitude\" ;\n", "\t\tlat:standard_name = \"latitude\" ;\n", "\tdouble lat_bnds(lat, bnds) ;\n", "\tdouble lon(lon) ;\n", "\t\tlon:bounds = \"lon_bnds\" ;\n", "\t\tlon:units = \"degrees_east\" ;\n", "\t\tlon:axis = \"X\" ;\n", "\t\tlon:long_name = \"Longitude\" ;\n", "\t\tlon:standard_name = \"longitude\" ;\n", "\tdouble lon_bnds(lon, bnds) ;\n", "\tdouble height ;\n", "\t\theight:units = \"m\" ;\n", "\t\theight:axis = \"Z\" ;\n", "\t\theight:positive = \"up\" ;\n", "\t\theight:long_name = \"height\" ;\n", "\t\theight:standard_name = \"height\" ;\n", "\tfloat tasmin(time, lat, lon) ;\n", "\t\ttasmin:standard_name = \"air_temperature\" ;\n", "\t\ttasmin:long_name = \"Daily Minimum Near-Surface Air Temperature\" ;\n", "\t\ttasmin:comment = \"minimum near-surface (usually, 2 meter) air temperature (add cell_method attribute \\'time: min\\')\" ;\n", "\t\ttasmin:units = \"K\" ;\n", "\t\ttasmin:cell_methods = \"area: mean time: minimum within days time: mean over days\" ;\n", "\t\ttasmin:cell_measures = \"area: areacella\" ;\n", "\t\ttasmin:history = \"2019-08-25T11:10:34Z altered by CMOR: Treated scalar dimension: \\'height\\'. 2019-08-25T11:10:34Z altered by CMOR: replaced missing value flag (-9e+33) and corresponding data with standard missing value (1e+20). 2019-08-25T11:10:34Z altered by CMOR: Inverted axis: lat.\" ;\n", "\t\ttasmin:coordinates = \"height\" ;\n", "\t\ttasmin:missing_value = 1.e+20f ;\n", "\t\ttasmin:_FillValue = 1.e+20f ;\n", "\n", "// global attributes:\n", "\t\t:Conventions = \"CF-1.7 CMIP-6.2\" ;\n", "\t\t:activity_id = \"CMIP\" ;\n", "\t\t:branch_method = \"standard\" ;\n", "\t\t:branch_time_in_child = 0. ;\n", "\t\t:branch_time_in_parent = 0. ;\n", "\t\t:contact = \"cmip6-mpi-esm@dkrz.de\" ;\n", "\t\t:creation_date = \"2019-08-25T11:10:34Z\" ;\n", "\t\t:data_specs_version = \"01.00.30\" ;\n", "\t\t:experiment = \"all-forcing simulation of the recent past\" ;\n", "\t\t:experiment_id = \"historical\" ;\n", "\t\t:external_variables = \"areacella\" ;\n", "\t\t:forcing_index = 1 ;\n", "\t\t:frequency = \"mon\" ;\n", "\t\t:further_info_url = \"https://furtherinfo.es-doc.org/CMIP6.MPI-M.MPI-ESM1-2-HR.historical.none.r1i1p1f1\" ;\n", "\t\t:grid = \"gn\" ;\n", "\t\t:grid_label = \"gn\" ;\n", "\t\t:history = \"2019-08-25T11:10:34Z ; CMOR rewrote data to be consistent with CMIP6, CF-1.7 CMIP-6.2 and CF standards.\" ;\n", "\t\t:initialization_index = 1 ;\n", "\t\t:institution = \"Max Planck Institute for Meteorology, Hamburg 20146, Germany\" ;\n", "\t\t:institution_id = \"MPI-M\" ;\n", "\t\t:mip_era = \"CMIP6\" ;\n", "\t\t:nominal_resolution = \"100 km\" ;\n", "\t\t:parent_activity_id = \"CMIP\" ;\n", "\t\t:parent_experiment_id = \"piControl\" ;\n", "\t\t:parent_mip_era = \"CMIP6\" ;\n", "\t\t:parent_source_id = \"MPI-ESM1-2-HR\" ;\n", "\t\t:parent_time_units = \"days since 1850-1-1 00:00:00\" ;\n", "\t\t:parent_variant_label = \"r1i1p1f1\" ;\n", "\t\t:physics_index = 1 ;\n", "\t\t:product = \"model-output\" ;\n", "\t\t:project_id = \"CMIP6\" ;\n", "\t\t:realization_index = 1 ;\n", "\t\t:realm = \"atmos\" ;\n", "\t\t:references = \"MPI-ESM: Mauritsen, T. et al. (2019), Developments in the MPI‐M Earth System Model version 1.2 (MPI‐ESM1.2) and Its Response to Increasing CO2, J. Adv. Model. Earth Syst.,11, 998-1038, doi:10.1029/2018MS001400,\\n\",\n", "\t\t\t\"Mueller, W.A. et al. (2018): A high‐resolution version of the Max Planck Institute Earth System Model MPI‐ESM1.2‐HR. J. Adv. Model. EarthSyst.,10,1383–1413, doi:10.1029/2017MS001217\" ;\n", "\t\t:source = \"MPI-ESM1.2-HR (2017): \\n\",\n", "\t\t\t\"aerosol: none, prescribed MACv2-SP\\n\",\n", "\t\t\t\"atmos: ECHAM6.3 (spectral T127; 384 x 192 longitude/latitude; 95 levels; top level 0.01 hPa)\\n\",\n", "\t\t\t\"atmosChem: none\\n\",\n", "\t\t\t\"land: JSBACH3.20\\n\",\n", "\t\t\t\"landIce: none/prescribed\\n\",\n", "\t\t\t\"ocean: MPIOM1.63 (tripolar TP04, approximately 0.4deg; 802 x 404 longitude/latitude; 40 levels; top grid cell 0-12 m)\\n\",\n", "\t\t\t\"ocnBgchem: HAMOCC6\\n\",\n", "\t\t\t\"seaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)\" ;\n", "\t\t:source_id = \"MPI-ESM1-2-HR\" ;\n", "\t\t:source_type = \"AOGCM\" ;\n", "\t\t:sub_experiment = \"none\" ;\n", "\t\t:sub_experiment_id = \"none\" ;\n", "\t\t:table_id = \"Amon\" ;\n", "\t\t:table_info = \"Creation Date:(09 May 2019) MD5:e6ef8ececc8f338646ebfb3aeed36bfc\" ;\n", "\t\t:title = \"MPI-ESM1-2-HR output prepared for CMIP6\" ;\n", "\t\t:variable_id = \"tasmin\" ;\n", "\t\t:variant_label = \"r1i1p1f1\" ;\n", "\t\t:license = \"CMIP6 model data produced by MPI-M is licensed under a Creative Commons Attribution ShareAlike 4.0 International License (https://creativecommons.org/licenses). Consult https://pcmdi.llnl.gov/CMIP6/TermsOfUse for terms of use governing CMIP6 output, including citation requirements and proper acknowledgment. Further information about this data, including some limitations, can be found via the further_info_url (recorded as a global attribute in this file) and. The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law.\" ;\n", "\t\t:cmor_version = \"3.5.0\" ;\n", "\t\t:tracking_id = \"hdl:21.14100/f6776bcc-3119-4f66-8ea8-94e12c626069\" ;\n", "}\n" ] }, { "data": { "text/plain": [ "0" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "os.system(f\"ncdump -h {file}\")" ] }, { "cell_type": "code", "execution_count": 8, "id": "19e1434c-2d76-4ead-969b-fba7a5b7b4a0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " File format : NetCDF4 classic zip\n", " -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter ID\n", " 1 : unknown MPI-ESM1.2-HR v instant 1 1 73728 1 F32z : -1 \n", " Grid coordinates :\n", " 1 : gaussian : points=73728 (384x192) F96\n", " lon : 0 to 359.0625 by 0.9375 degrees_east circular\n", " lat : -89.28423 to 89.28423 degrees_north\n", " available : cellbounds\n", " Vertical coordinates :\n", " 1 : height : levels=1 scalar\n", " height : 2 m\n", " Time coordinate :\n", " time : 60 steps\n", " RefTime = 1850-01-01 00:00:00 Units = days Calendar = proleptic_gregorian Bounds = true\n", " YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss\n", " 2010-01-16 12:00:00 2010-02-15 00:00:00 2010-03-16 12:00:00 2010-04-16 00:00:00\n", " 2010-05-16 12:00:00 2010-06-16 00:00:00 2010-07-16 12:00:00 2010-08-16 12:00:00\n", " 2010-09-16 00:00:00 2010-10-16 12:00:00 2010-11-16 00:00:00 2010-12-16 12:00:00\n", " 2011-01-16 12:00:00 2011-02-15 00:00:00 2011-03-16 12:00:00 2011-04-16 00:00:00\n", " 2011-05-16 12:00:00 2011-06-16 00:00:00 2011-07-16 12:00:00 2011-08-16 12:00:00\n", " 2011-09-16 00:00:00 2011-10-16 12:00:00 2011-11-16 00:00:00 2011-12-16 12:00:00\n", " 2012-01-16 12:00:00 2012-02-15 12:00:00 2012-03-16 12:00:00 2012-04-16 00:00:00\n", " 2012-05-16 12:00:00 2012-06-16 00:00:00 2012-07-16 12:00:00 2012-08-16 12:00:00\n", " 2012-09-16 00:00:00 2012-10-16 12:00:00 2012-11-16 00:00:00 2012-12-16 12:00:00\n", " 2013-01-16 12:00:00 2013-02-15 00:00:00 2013-03-16 12:00:00 2013-04-16 00:00:00\n", " 2013-05-16 12:00:00 2013-06-16 00:00:00 2013-07-16 12:00:00 2013-08-16 12:00:00\n", " 2013-09-16 00:00:00 2013-10-16 12:00:00 2013-11-16 00:00:00 2013-12-16 12:00:00\n", " 2014-01-16 12:00:00 2014-02-15 00:00:00 2014-03-16 12:00:00 2014-04-16 00:00:00\n", " 2014-05-16 12:00:00 2014-06-16 00:00:00 2014-07-16 12:00:00 2014-08-16 12:00:00\n", " 2014-09-16 00:00:00 2014-10-16 12:00:00 2014-11-16 00:00:00 2014-12-16 12:00:00\n", "cdo sinfo: Processed 1 variable over 60 timesteps [0.05s 19MB].\n" ] }, { "data": { "text/plain": [ "0" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "os.system(f\"cdo sinfo {file}\")" ] }, { "cell_type": "markdown", "id": "4973f6fd-e579-4eeb-b43c-e1dd046e49d1", "metadata": {}, "source": [ "## Get subset file" ] }, { "cell_type": "code", "execution_count": 9, "id": "acb91603-66be-49cd-af1c-ac60a62ab7b2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "resp = rooki.subset(\n", " # collection=\"c3s-cmip6.CMIP.CSIRO-ARCCSS.ACCESS-CM2.historical.r1i1p1f1.day.tasmin.gn.v20191108\",\n", " collection=\"c3s-cmip6.CMIP.MPI-M.MPI-ESM1-2-HR.historical.r1i1p1f1.Amon.tasmin.gn.v20190710\",\n", " time='2010-01-01/2010-12-31',\n", " #area='58,-33,13,21'\n", " original_files=False,\n", ")\n", "resp.ok" ] }, { "cell_type": "code", "execution_count": 10, "id": "4ae56878-b549-4f1d-9583-79dea3c446dc", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Downloading to /var/folders/qb/mg0csz190wd4rxybhhnwjln80000gn/T/metalink_s4nk9xm4/tasmin_Amon_MPI-ESM1-2-HR_historical_r1i1p1f1_gn_20100116-20101216.nc.\n" ] } ], "source": [ "ds = resp.datasets()[0]\n", "#ds" ] }, { "cell_type": "code", "execution_count": 11, "id": "8e02e166-3a7b-457e-a3f6-6dde8bed80c0", "metadata": {}, "outputs": [], "source": [ "# ds.tasmin.isel(time=0).plot()" ] }, { "cell_type": "code", "execution_count": 12, "id": "a9723ff8-c966-4b3d-b53f-1b461864d941", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Already downloaded tasmin_Amon_MPI-ESM1-2-HR_historical_r1i1p1f1_gn_20100116-20101216.nc.\n" ] }, { "data": { "text/plain": [ "'/var/folders/qb/mg0csz190wd4rxybhhnwjln80000gn/T/metalink_s4nk9xm4/tasmin_Amon_MPI-ESM1-2-HR_historical_r1i1p1f1_gn_20100116-20101216.nc'" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "file = resp.download()[0]\n", "file" ] }, { "cell_type": "code", "execution_count": 13, "id": "1f429496-f834-42ef-a2ab-22e804abc926", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "netcdf tasmin_Amon_MPI-ESM1-2-HR_historical_r1i1p1f1_gn_20100116-20101216 {\n", "dimensions:\n", "\ttime = UNLIMITED ; // (12 currently)\n", "\tbnds = 2 ;\n", "\tlat = 192 ;\n", "\tlon = 384 ;\n", "variables:\n", "\tdouble time(time) ;\n", "\t\ttime:bounds = \"time_bnds\" ;\n", "\t\ttime:axis = \"T\" ;\n", "\t\ttime:long_name = \"time\" ;\n", "\t\ttime:standard_name = \"time\" ;\n", "\t\ttime:units = \"days since 1850-01-01\" ;\n", "\t\ttime:calendar = \"proleptic_gregorian\" ;\n", "\tdouble time_bnds(time, bnds) ;\n", "\tdouble lat(lat) ;\n", "\t\tlat:bounds = \"lat_bnds\" ;\n", "\t\tlat:units = \"degrees_north\" ;\n", "\t\tlat:axis = \"Y\" ;\n", "\t\tlat:long_name = \"Latitude\" ;\n", "\t\tlat:standard_name = \"latitude\" ;\n", "\tdouble lat_bnds(lat, bnds) ;\n", "\tdouble lon(lon) ;\n", "\t\tlon:bounds = \"lon_bnds\" ;\n", "\t\tlon:units = \"degrees_east\" ;\n", "\t\tlon:axis = \"X\" ;\n", "\t\tlon:long_name = \"Longitude\" ;\n", "\t\tlon:standard_name = \"longitude\" ;\n", "\tdouble lon_bnds(lon, bnds) ;\n", "\tdouble height ;\n", "\t\theight:units = \"m\" ;\n", "\t\theight:axis = \"Z\" ;\n", "\t\theight:positive = \"up\" ;\n", "\t\theight:long_name = \"height\" ;\n", "\t\theight:standard_name = \"height\" ;\n", "\tfloat tasmin(time, lat, lon) ;\n", "\t\ttasmin:_FillValue = 1.e+20f ;\n", "\t\ttasmin:standard_name = \"air_temperature\" ;\n", "\t\ttasmin:long_name = \"Daily Minimum Near-Surface Air Temperature\" ;\n", "\t\ttasmin:comment = \"minimum near-surface (usually, 2 meter) air temperature (add cell_method attribute \\'time: min\\')\" ;\n", "\t\ttasmin:units = \"K\" ;\n", "\t\ttasmin:cell_methods = \"area: mean time: minimum within days time: mean over days\" ;\n", "\t\ttasmin:cell_measures = \"area: areacella\" ;\n", "\t\ttasmin:history = \"2019-08-25T11:10:34Z altered by CMOR: Treated scalar dimension: \\'height\\'. 2019-08-25T11:10:34Z altered by CMOR: replaced missing value flag (-9e+33) and corresponding data with standard missing value (1e+20). 2019-08-25T11:10:34Z altered by CMOR: Inverted axis: lat.\" ;\n", "\t\ttasmin:coordinates = \"height\" ;\n", "\t\ttasmin:missing_value = 1.e+20f ;\n", "\n", "// global attributes:\n", "\t\t:Conventions = \"CF-1.7 CMIP-6.2\" ;\n", "\t\t:activity_id = \"CMIP\" ;\n", "\t\t:branch_method = \"standard\" ;\n", "\t\t:branch_time_in_child = 0. ;\n", "\t\t:branch_time_in_parent = 0. ;\n", "\t\t:contact = \"cmip6-mpi-esm@dkrz.de\" ;\n", "\t\t:creation_date = \"2019-08-25T11:10:34Z\" ;\n", "\t\t:data_specs_version = \"01.00.30\" ;\n", "\t\t:experiment = \"all-forcing simulation of the recent past\" ;\n", "\t\t:experiment_id = \"historical\" ;\n", "\t\t:external_variables = \"areacella\" ;\n", "\t\t:forcing_index = 1 ;\n", "\t\t:frequency = \"mon\" ;\n", "\t\t:further_info_url = \"https://furtherinfo.es-doc.org/CMIP6.MPI-M.MPI-ESM1-2-HR.historical.none.r1i1p1f1\" ;\n", "\t\t:grid = \"gn\" ;\n", "\t\t:grid_label = \"gn\" ;\n", "\t\t:history = \"2019-08-25T11:10:34Z ; CMOR rewrote data to be consistent with CMIP6, CF-1.7 CMIP-6.2 and CF standards.\" ;\n", "\t\t:initialization_index = 1 ;\n", "\t\t:institution = \"Max Planck Institute for Meteorology, Hamburg 20146, Germany\" ;\n", "\t\t:institution_id = \"MPI-M\" ;\n", "\t\t:mip_era = \"CMIP6\" ;\n", "\t\t:nominal_resolution = \"100 km\" ;\n", "\t\t:parent_activity_id = \"CMIP\" ;\n", "\t\t:parent_experiment_id = \"piControl\" ;\n", "\t\t:parent_mip_era = \"CMIP6\" ;\n", "\t\t:parent_source_id = \"MPI-ESM1-2-HR\" ;\n", "\t\t:parent_time_units = \"days since 1850-1-1 00:00:00\" ;\n", "\t\t:parent_variant_label = \"r1i1p1f1\" ;\n", "\t\t:physics_index = 1 ;\n", "\t\t:product = \"model-output\" ;\n", "\t\t:project_id = \"CMIP6\" ;\n", "\t\t:realization_index = 1 ;\n", "\t\t:realm = \"atmos\" ;\n", "\t\tstring :references = \"MPI-ESM: Mauritsen, T. et al. (2019), Developments in the MPI‐M Earth System Model version 1.2 (MPI‐ESM1.2) and Its Response to Increasing CO2, J. Adv. Model. Earth Syst.,11, 998-1038, doi:10.1029/2018MS001400,\\nMueller, W.A. et al. (2018): A high‐resolution version of the Max Planck Institute Earth System Model MPI‐ESM1.2‐HR. J. Adv. Model. EarthSyst.,10,1383–1413, doi:10.1029/2017MS001217\" ;\n", "\t\t:source = \"MPI-ESM1.2-HR (2017): \\naerosol: none, prescribed MACv2-SP\\natmos: ECHAM6.3 (spectral T127; 384 x 192 longitude/latitude; 95 levels; top level 0.01 hPa)\\natmosChem: none\\nland: JSBACH3.20\\nlandIce: none/prescribed\\nocean: MPIOM1.63 (tripolar TP04, approximately 0.4deg; 802 x 404 longitude/latitude; 40 levels; top grid cell 0-12 m)\\nocnBgchem: HAMOCC6\\nseaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)\" ;\n", "\t\t:source_id = \"MPI-ESM1-2-HR\" ;\n", "\t\t:source_type = \"AOGCM\" ;\n", "\t\t:sub_experiment = \"none\" ;\n", "\t\t:sub_experiment_id = \"none\" ;\n", "\t\t:table_id = \"Amon\" ;\n", "\t\t:table_info = \"Creation Date:(09 May 2019) MD5:e6ef8ececc8f338646ebfb3aeed36bfc\" ;\n", "\t\t:title = \"MPI-ESM1-2-HR output prepared for CMIP6\" ;\n", "\t\t:variable_id = \"tasmin\" ;\n", "\t\t:variant_label = \"r1i1p1f1\" ;\n", "\t\t:license = \"CMIP6 model data produced by MPI-M is licensed under a Creative Commons Attribution ShareAlike 4.0 International License (https://creativecommons.org/licenses). Consult https://pcmdi.llnl.gov/CMIP6/TermsOfUse for terms of use governing CMIP6 output, including citation requirements and proper acknowledgment. Further information about this data, including some limitations, can be found via the further_info_url (recorded as a global attribute in this file) and. The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law.\" ;\n", "\t\t:cmor_version = \"3.5.0\" ;\n", "\t\t:tracking_id = \"hdl:21.14100/f6776bcc-3119-4f66-8ea8-94e12c626069\" ;\n", "}\n" ] }, { "data": { "text/plain": [ "0" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "os.system(f\"ncdump -h {file}\")" ] }, { "cell_type": "code", "execution_count": 14, "id": "ea6f2bad-5ac4-49d4-a3fc-7425f93562ff", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " File format : NetCDF4 zip\n", " -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter ID\n", " 1 : unknown MPI-ESM1.2-HR v instant 1 1 73728 1 F32z : -1 \n", " Grid coordinates :\n", " 1 : gaussian : points=73728 (384x192) F96\n", " lon : 0 to 359.0625 by 0.9375 degrees_east circular\n", " lat : -89.28423 to 89.28423 degrees_north\n", " available : cellbounds\n", " Vertical coordinates :\n", " 1 : height : levels=1 scalar\n", " height : 2 m\n", " Time coordinate :\n", " time : 12 steps\n", " RefTime = 1850-01-01 00:00:00 Units = days Calendar = proleptic_gregorian Bounds = true\n", " YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss\n", " 2010-01-16 12:00:00 2010-02-15 00:00:00 2010-03-16 12:00:00 2010-04-16 00:00:00\n", " 2010-05-16 12:00:00 2010-06-16 00:00:00 2010-07-16 12:00:00 2010-08-16 12:00:00\n", " 2010-09-16 00:00:00 2010-10-16 12:00:00 2010-11-16 00:00:00 2010-12-16 12:00:00\n", "cdo sinfo: Processed 1 variable over 12 timesteps [0.02s 19MB].\n" ] }, { "data": { "text/plain": [ "0" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "os.system(f\"cdo sinfo {file}\")" ] }, { "cell_type": "markdown", "id": "8152cb1e-9705-4aba-a74a-19bfc14444cd", "metadata": {}, "source": [ "## Fix bounds?\n", "\n", "Fix is now applied in clisops 0.9.1:\n", "https://github.com/roocs/clisops/releases/tag/v0.9.1\n", "\n", "* https://github.com/pydata/xarray/issues/5510\n", "* https://github.com/pydata/xarray/pull/5514" ] }, { "cell_type": "code", "execution_count": 15, "id": "928a249e-9843-476e-898a-5b59414c4cb3", "metadata": {}, "outputs": [], "source": [ "ds.time.encoding[\"_FillValue\"] = None\n", "ds.lon.encoding[\"_FillValue\"] = None\n", "ds.lat.encoding[\"_FillValue\"] = None\n", "ds.height.encoding[\"_FillValue\"] = None\n", "\n", "ds.lat_bnds.encoding[\"_FillValue\"] = None\n", "ds.lat_bnds.encoding[\"coordinates\"] = None\n", "#ds.lat_bnds.attrs[\"coordinates\"] = None\n", "#ds.lat_bnds.reset_coords(\"height\", drop=True)\n", "\n", "ds.lon_bnds.encoding[\"_FillValue\"] = None\n", "ds.lon_bnds.encoding[\"coordinates\"] = None\n", "\n", "ds.time_bnds.encoding[\"_FillValue\"] = None\n", "ds.time_bnds.encoding[\"coordinates\"] = None\n", "\n", "#ds" ] }, { "cell_type": "code", "execution_count": 16, "id": "c690bf8d-c2f7-4689-840f-7c24b37f390f", "metadata": {}, "outputs": [], "source": [ "ds.to_netcdf(\"/tmp/out.nc\")" ] }, { "cell_type": "code", "execution_count": 17, "id": "52e37a96-096a-4f39-b2c6-cccfad79636d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " File format : NetCDF4 zip\n", " -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter ID\n", " 1 : unknown MPI-ESM1.2-HR v instant 1 1 73728 1 F32z : -1 \n", " Grid coordinates :\n", " 1 : gaussian : points=73728 (384x192) F96\n", " lon : 0 to 359.0625 by 0.9375 degrees_east circular\n", " lat : -89.28423 to 89.28423 degrees_north\n", " available : cellbounds\n", " Vertical coordinates :\n", " 1 : height : levels=1 scalar\n", " height : 2 m\n", " Time coordinate :\n", " time : 12 steps\n", " RefTime = 1850-01-01 00:00:00 Units = days Calendar = proleptic_gregorian Bounds = true\n", " YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss\n", " 2010-01-16 12:00:00 2010-02-15 00:00:00 2010-03-16 12:00:00 2010-04-16 00:00:00\n", " 2010-05-16 12:00:00 2010-06-16 00:00:00 2010-07-16 12:00:00 2010-08-16 12:00:00\n", " 2010-09-16 00:00:00 2010-10-16 12:00:00 2010-11-16 00:00:00 2010-12-16 12:00:00\n", "cdo sinfo: Processed 1 variable over 12 timesteps [0.02s 19MB].\n" ] }, { "data": { "text/plain": [ "0" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "os.system(\"cdo sinfo /tmp/out.nc\")" ] }, { "cell_type": "code", "execution_count": 18, "id": "0e126582-5d63-485f-ad00-da6ef23cf729", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "netcdf out {\n", "dimensions:\n", "\ttime = UNLIMITED ; // (12 currently)\n", "\tbnds = 2 ;\n", "\tlat = 192 ;\n", "\tlon = 384 ;\n", "variables:\n", "\tdouble time(time) ;\n", "\t\ttime:bounds = \"time_bnds\" ;\n", "\t\ttime:axis = \"T\" ;\n", "\t\ttime:long_name = \"time\" ;\n", "\t\ttime:standard_name = \"time\" ;\n", "\t\ttime:units = \"days since 1850-01-01\" ;\n", "\t\ttime:calendar = \"proleptic_gregorian\" ;\n", "\tdouble time_bnds(time, bnds) ;\n", "\tdouble lat(lat) ;\n", "\t\tlat:bounds = \"lat_bnds\" ;\n", "\t\tlat:units = \"degrees_north\" ;\n", "\t\tlat:axis = \"Y\" ;\n", "\t\tlat:long_name = \"Latitude\" ;\n", "\t\tlat:standard_name = \"latitude\" ;\n", "\tdouble lat_bnds(lat, bnds) ;\n", "\tdouble lon(lon) ;\n", "\t\tlon:bounds = \"lon_bnds\" ;\n", "\t\tlon:units = \"degrees_east\" ;\n", "\t\tlon:axis = \"X\" ;\n", "\t\tlon:long_name = \"Longitude\" ;\n", "\t\tlon:standard_name = \"longitude\" ;\n", "\tdouble lon_bnds(lon, bnds) ;\n", "\tdouble height ;\n", "\t\theight:units = \"m\" ;\n", "\t\theight:axis = \"Z\" ;\n", "\t\theight:positive = \"up\" ;\n", "\t\theight:long_name = \"height\" ;\n", "\t\theight:standard_name = \"height\" ;\n", "\tfloat tasmin(time, lat, lon) ;\n", "\t\ttasmin:_FillValue = 1.e+20f ;\n", "\t\ttasmin:standard_name = \"air_temperature\" ;\n", "\t\ttasmin:long_name = \"Daily Minimum Near-Surface Air Temperature\" ;\n", "\t\ttasmin:comment = \"minimum near-surface (usually, 2 meter) air temperature (add cell_method attribute \\'time: min\\')\" ;\n", "\t\ttasmin:units = \"K\" ;\n", "\t\ttasmin:cell_methods = \"area: mean time: minimum within days time: mean over days\" ;\n", "\t\ttasmin:cell_measures = \"area: areacella\" ;\n", "\t\ttasmin:history = \"2019-08-25T11:10:34Z altered by CMOR: Treated scalar dimension: \\'height\\'. 2019-08-25T11:10:34Z altered by CMOR: replaced missing value flag (-9e+33) and corresponding data with standard missing value (1e+20). 2019-08-25T11:10:34Z altered by CMOR: Inverted axis: lat.\" ;\n", "\t\ttasmin:coordinates = \"height\" ;\n", "\t\ttasmin:missing_value = 1.e+20f ;\n", "\n", "// global attributes:\n", "\t\t:Conventions = \"CF-1.7 CMIP-6.2\" ;\n", "\t\t:activity_id = \"CMIP\" ;\n", "\t\t:branch_method = \"standard\" ;\n", "\t\t:branch_time_in_child = 0. ;\n", "\t\t:branch_time_in_parent = 0. ;\n", "\t\t:contact = \"cmip6-mpi-esm@dkrz.de\" ;\n", "\t\t:creation_date = \"2019-08-25T11:10:34Z\" ;\n", "\t\t:data_specs_version = \"01.00.30\" ;\n", "\t\t:experiment = \"all-forcing simulation of the recent past\" ;\n", "\t\t:experiment_id = \"historical\" ;\n", "\t\t:external_variables = \"areacella\" ;\n", "\t\t:forcing_index = 1 ;\n", "\t\t:frequency = \"mon\" ;\n", "\t\t:further_info_url = \"https://furtherinfo.es-doc.org/CMIP6.MPI-M.MPI-ESM1-2-HR.historical.none.r1i1p1f1\" ;\n", "\t\t:grid = \"gn\" ;\n", "\t\t:grid_label = \"gn\" ;\n", "\t\t:history = \"2019-08-25T11:10:34Z ; CMOR rewrote data to be consistent with CMIP6, CF-1.7 CMIP-6.2 and CF standards.\" ;\n", "\t\t:initialization_index = 1 ;\n", "\t\t:institution = \"Max Planck Institute for Meteorology, Hamburg 20146, Germany\" ;\n", "\t\t:institution_id = \"MPI-M\" ;\n", "\t\t:mip_era = \"CMIP6\" ;\n", "\t\t:nominal_resolution = \"100 km\" ;\n", "\t\t:parent_activity_id = \"CMIP\" ;\n", "\t\t:parent_experiment_id = \"piControl\" ;\n", "\t\t:parent_mip_era = \"CMIP6\" ;\n", "\t\t:parent_source_id = \"MPI-ESM1-2-HR\" ;\n", "\t\t:parent_time_units = \"days since 1850-1-1 00:00:00\" ;\n", "\t\t:parent_variant_label = \"r1i1p1f1\" ;\n", "\t\t:physics_index = 1 ;\n", "\t\t:product = \"model-output\" ;\n", "\t\t:project_id = \"CMIP6\" ;\n", "\t\t:realization_index = 1 ;\n", "\t\t:realm = \"atmos\" ;\n", "\t\tstring :references = \"MPI-ESM: Mauritsen, T. et al. (2019), Developments in the MPI‐M Earth System Model version 1.2 (MPI‐ESM1.2) and Its Response to Increasing CO2, J. Adv. Model. Earth Syst.,11, 998-1038, doi:10.1029/2018MS001400,\\nMueller, W.A. et al. (2018): A high‐resolution version of the Max Planck Institute Earth System Model MPI‐ESM1.2‐HR. J. Adv. Model. EarthSyst.,10,1383–1413, doi:10.1029/2017MS001217\" ;\n", "\t\t:source = \"MPI-ESM1.2-HR (2017): \\naerosol: none, prescribed MACv2-SP\\natmos: ECHAM6.3 (spectral T127; 384 x 192 longitude/latitude; 95 levels; top level 0.01 hPa)\\natmosChem: none\\nland: JSBACH3.20\\nlandIce: none/prescribed\\nocean: MPIOM1.63 (tripolar TP04, approximately 0.4deg; 802 x 404 longitude/latitude; 40 levels; top grid cell 0-12 m)\\nocnBgchem: HAMOCC6\\nseaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)\" ;\n", "\t\t:source_id = \"MPI-ESM1-2-HR\" ;\n", "\t\t:source_type = \"AOGCM\" ;\n", "\t\t:sub_experiment = \"none\" ;\n", "\t\t:sub_experiment_id = \"none\" ;\n", "\t\t:table_id = \"Amon\" ;\n", "\t\t:table_info = \"Creation Date:(09 May 2019) MD5:e6ef8ececc8f338646ebfb3aeed36bfc\" ;\n", "\t\t:title = \"MPI-ESM1-2-HR output prepared for CMIP6\" ;\n", "\t\t:variable_id = \"tasmin\" ;\n", "\t\t:variant_label = \"r1i1p1f1\" ;\n", "\t\t:license = \"CMIP6 model data produced by MPI-M is licensed under a Creative Commons Attribution ShareAlike 4.0 International License (https://creativecommons.org/licenses). Consult https://pcmdi.llnl.gov/CMIP6/TermsOfUse for terms of use governing CMIP6 output, including citation requirements and proper acknowledgment. Further information about this data, including some limitations, can be found via the further_info_url (recorded as a global attribute in this file) and. The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law.\" ;\n", "\t\t:cmor_version = \"3.5.0\" ;\n", "\t\t:tracking_id = \"hdl:21.14100/f6776bcc-3119-4f66-8ea8-94e12c626069\" ;\n", "}\n" ] }, { "data": { "text/plain": [ "0" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "os.system(\"ncdump -h /tmp/out.nc\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.4" } }, "nbformat": 4, "nbformat_minor": 5 }