diff --git a/notebooks/conversion_output/convert_MIMICA_output_to_dephy_format.ipynb b/notebooks/conversion_output/convert_MIMICA_output_to_dephy_format.ipynb index fa10e155..ec661e03 100644 --- a/notebooks/conversion_output/convert_MIMICA_output_to_dephy_format.ipynb +++ b/notebooks/conversion_output/convert_MIMICA_output_to_dephy_format.ipynb @@ -2,199 +2,1486 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, - "metadata": { - "metadata": {} - }, + "execution_count": 2, + "id": "5144ae7a", + "metadata": {}, "outputs": [], "source": [ - "import os, pickle, io\n", - "import numpy as np\n", "import xarray as xr\n", + "import pandas as pd\n", + "import numpy as np\n", "import matplotlib.pyplot as plt\n", + "import csv\n", + "import os\n", + "import netCDF4\n", "import datetime\n", - "import re\n" + "from netCDF4 import Dataset\n", + "import re" ] }, { "cell_type": "code", - "execution_count": 2, - "metadata": { - "metadata": {} - }, + "execution_count": 3, + "id": "94b5cbc4", + "metadata": {}, "outputs": [], "source": [ "native_outputs_path='/proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_NEW_SIMULATIONS/'\n", "converted_outputs_path='/proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED/'\n", - "converted_outputs_path_time_mod='/proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/'\n", - "#COMBLE_part2='/proj/mimica-chalmers-comble/users/x_abaro/COMBLE/'" + "converted_outputs_path_time_mod='/proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/'" ] }, { "cell_type": "code", - "execution_count": 3, - "metadata": { - "metadata": {} - }, + "execution_count": 4, + "id": "f65f2c5d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
standard_namevariable_idunitsdimensionscomment (10-min average reported at endpoints, green=minimum)
0timetimesdimension, seconds since 2020-03-12 22:00:00
1heightzfmdimension, altitude of mid-level points above ...
2layer_top_heightzemdimension, altitude of layer top points above ...
3surface_pressurepsPatime
4surface_temperaturetsKtime
5surface_friction_velocityustarm s-1time
6surface_roughness_length_for_momentum_in_airz0mtime
7surface_roughness_length_for_heat_in_airz0hmtime
8surface_roughness_length_for_humidity_in_airz0qmtime
9surface_upward_sensible_heat_fluxhfssW m-2time
10surface_upward_latent_heat_fluxhflsW m-2time
11obukhov_lengtholmtime
12atmosphere_mass_content_of_liquid_cloud_waterlwpckg m-2timedefault breakdown to cloud water and rain in a...
13atmosphere_mass_content_of_rain_waterlwprkg m-2time
14atmosphere_mass_content_of_ice_wateriwpkg m-2timeall ice-phase hydrometeors
15cloud_area_fractionclt1timefraction of atmospheric columns with total hyd...
16optical_depthod1timescene (all sky); mid-visible, all hydrometeors...
17optical_depth_of_liquid_cloudodlc1timeas for optical_depth but cloud droplets only
18precipitation_flux_at_surfaceprkg m-2 s-1timeliquid and ice phase, all hydrometeors
19precipitation_flux_at_surface_in_ice_phaseprikg m-2 s-1timeice phase hydrometeors only
20toa_outgoing_longwave_fluxrlutW m-2timeat top of atmosphere
21surface_downwelling_longwave_fluxrldsW m-2time
22surface_upwelling_longwave_fluxrlusW m-2time
23surface_sea_spray_number_fluxssafm-2 s-1timewhen using prognostic aerosol; emission only (...
24air_pressurepaPatime, height
25eastward_winduam s-1time, height
26northward_windvam s-1time, height
27air_dry_densityrhoakg m-3time, height
28air_temperaturetaKtime, height
29water_vapor_mixing_ratioqvkg kg-1time, heightper kg dry air
30relative_humidityhur1time, heightrelative to liquid
31relative_humidity_over_icehuri1time, heightrelative to ice
32air_potential_temperaturethetaKtime, height
33specific_turbulent_kinetic_energy_resolvedtke_resm2 s-2time, heightresolved only; compute mean values horizontall...
34specific_turbulent_kinetic_energy_sgstke_sgsm2 s-2time, heightSGS only
35mass_mixing_ratio_of_cloud_liquid_water_in_airqlckg kg-1time, heightscene (all sky) per kg dry air; default breakd...
36mass_mixing_ratio_of_rain_water_in_airqlrkg kg-1time, height
37mass_mixing_ratio_of_cloud_ice_in_airqickg kg-1time, heightdefault breakdown to cloud_ice, snow and graup...
38mass_mixing_ratio_of_snow_in_airqiskg kg-1time, height
39mass_mixing_ratio_of_graupel_in_airqigkg kg-1time, height
40number_of_liquid_cloud_droplets_in_airnlckg-1time, heightscene (all sky) per kg dry air; default breakd...
41number_of_rain_drops_in_airnlrkg-1time, height
42number_of_cloud_ice_crystals_in_airnickg-1time, heightdefault breakdown to cloud_ice, snow and graup...
43number_of_snow_crystals_in_airniskg-1time, height
44number_of_graupel_crystals_in_airnigkg-1time, height
45number_of_total_aerosol_mode1na1kg-1time, heightwhen using prognostic aerosol; scene (all sky)...
46number_of_total_aerosol_mode2na2kg-1time, heightaccumulation mode
47number_of_total_aerosol_mode3na3kg-1time, heightsea spray mode
48number_of_liquid_cloud_droplets_in_cloudnlcickg-1time, heightper kg dry air where cloud water > 0.01 g/kg; ...
49number_of_ice_crystals_in_cloudniickg-1time, heighttotal ice hydrometeors per kg dry air where cl...
50dissipation_rate_of_turbulent_kinetic_energyepsm2 s-3time, heighttotal (including numerical diffusion contribut...
51zonal_momentum_fluxuwm2 s-2time, heighttotal (resolved plus SGS); for resolved compon...
52meridional_momentum_fluxvwm2 s-2time, heighttotal (resolved plus SGS); for resolved compon...
53variance_of_upward_air_velocityw2m2 s-2time, heighttotal (resolved plus SGS); for resolved compon...
54vertical_flux_potential_temperaturewthK m s-1time, heighttotal (resolved plus SGS); for resolved compon...
55vertical_flux_liquid_ice_water_potential_tempe...vf_thliK m s-1time, heighttotal (resolved plus SGS); include sedimentati...
56vertical_flux_water_vaporwqvkg kg-1 m s-1time, heighttotal (resolved plus SGS); for resolved compon...
57vertical_flux_total_watervf_qtkg kg-1 m s-1time, heighttotal (resolved plus SGS); vapor+all liquid+al...
58area_fraction_of_liquid_cloudflc1time, heightfraction of cells with cloud water threshold o...
59precipitation_flux_in_airprfkg m-2 s-1time, heightliquid and ice phase, all hydrometeors
60precipitation_flux_in_air_in_ice_phaseprfikg m-2 s-1time, height
61downwelling_longwave_flux_in_airrldW m-2time, height
62upwelling_longwave_flux_in_airrluW m-2time, height
63tendency_of_air_potential_temperature_due_to_r...dth_radK s-1time, height
64tendency_of_air_potential_temperature_due_to_m...dth_microK s-1time, heightincluding net condensation and precipitation
65tendency_of_air_potential_temperature_due_to_m...dth_turbK s-1time, heightincluding surface fluxes
66tendency_of_water_vapor_mixing_ratio_due_to_mi...dq_microkg kg-1 s-1time, heightincluding net condensation and precipitation
67tendency_of_water_vapor_mixing_ratio_due_to_mi...dq_turbkg kg-1 s-1time, heightincluding surface fluxes
68tendency_of_aerosol_number_due_to_warm_microph...dna_micro_warmkg-1 s-1time, heightactivated and unactivated aerosol (sum over al...
69tendency_of_aerosol_number_due_to_cold_microph...dna_micro_coldkg-1 s-1time, heightactivated and unactivated aerosol (sum over al...
70tendency_of_aerosol_number_due_to_mixingdna_turbkg-1 s-1time, heightactivated and unactivated aerosol (sum over al...
71tendency_of_ice_number_due_to_heterogeneous_fr...dni_hetkg-1 s-1time, heightsum of primary ice nucleation due to activatio...
72tendency_of_ice_number_due_to_secondary_ice_pr...dni_sipkg-1 s-1time, heightsum of secondary ice formation processes (e.g....
73tendency_of_ice_number_due_to_homogeneous_free...dni_homkg-1 s-1time, heightice nucleation source due to homogoeneous free...
\n", + "
" + ], + "text/plain": [ + " standard_name variable_id \\\n", + "0 time time \n", + "1 height zf \n", + "2 layer_top_height ze \n", + "3 surface_pressure ps \n", + "4 surface_temperature ts \n", + "5 surface_friction_velocity ustar \n", + "6 surface_roughness_length_for_momentum_in_air z0 \n", + "7 surface_roughness_length_for_heat_in_air z0h \n", + "8 surface_roughness_length_for_humidity_in_air z0q \n", + "9 surface_upward_sensible_heat_flux hfss \n", + "10 surface_upward_latent_heat_flux hfls \n", + "11 obukhov_length ol \n", + "12 atmosphere_mass_content_of_liquid_cloud_water lwpc \n", + "13 atmosphere_mass_content_of_rain_water lwpr \n", + "14 atmosphere_mass_content_of_ice_water iwp \n", + "15 cloud_area_fraction clt \n", + "16 optical_depth od \n", + "17 optical_depth_of_liquid_cloud odlc \n", + "18 precipitation_flux_at_surface pr \n", + "19 precipitation_flux_at_surface_in_ice_phase pri \n", + "20 toa_outgoing_longwave_flux rlut \n", + "21 surface_downwelling_longwave_flux rlds \n", + "22 surface_upwelling_longwave_flux rlus \n", + "23 surface_sea_spray_number_flux ssaf \n", + "24 air_pressure pa \n", + "25 eastward_wind ua \n", + "26 northward_wind va \n", + "27 air_dry_density rhoa \n", + "28 air_temperature ta \n", + "29 water_vapor_mixing_ratio qv \n", + "30 relative_humidity hur \n", + "31 relative_humidity_over_ice huri \n", + "32 air_potential_temperature theta \n", + "33 specific_turbulent_kinetic_energy_resolved tke_res \n", + "34 specific_turbulent_kinetic_energy_sgs tke_sgs \n", + "35 mass_mixing_ratio_of_cloud_liquid_water_in_air qlc \n", + "36 mass_mixing_ratio_of_rain_water_in_air qlr \n", + "37 mass_mixing_ratio_of_cloud_ice_in_air qic \n", + "38 mass_mixing_ratio_of_snow_in_air qis \n", + "39 mass_mixing_ratio_of_graupel_in_air qig \n", + "40 number_of_liquid_cloud_droplets_in_air nlc \n", + "41 number_of_rain_drops_in_air nlr \n", + "42 number_of_cloud_ice_crystals_in_air nic \n", + "43 number_of_snow_crystals_in_air nis \n", + "44 number_of_graupel_crystals_in_air nig \n", + "45 number_of_total_aerosol_mode1 na1 \n", + "46 number_of_total_aerosol_mode2 na2 \n", + "47 number_of_total_aerosol_mode3 na3 \n", + "48 number_of_liquid_cloud_droplets_in_cloud nlcic \n", + "49 number_of_ice_crystals_in_cloud niic \n", + "50 dissipation_rate_of_turbulent_kinetic_energy eps \n", + "51 zonal_momentum_flux uw \n", + "52 meridional_momentum_flux vw \n", + "53 variance_of_upward_air_velocity w2 \n", + "54 vertical_flux_potential_temperature wth \n", + "55 vertical_flux_liquid_ice_water_potential_tempe... vf_thli \n", + "56 vertical_flux_water_vapor wqv \n", + "57 vertical_flux_total_water vf_qt \n", + "58 area_fraction_of_liquid_cloud flc \n", + "59 precipitation_flux_in_air prf \n", + "60 precipitation_flux_in_air_in_ice_phase prfi \n", + "61 downwelling_longwave_flux_in_air rld \n", + "62 upwelling_longwave_flux_in_air rlu \n", + "63 tendency_of_air_potential_temperature_due_to_r... dth_rad \n", + "64 tendency_of_air_potential_temperature_due_to_m... dth_micro \n", + "65 tendency_of_air_potential_temperature_due_to_m... dth_turb \n", + "66 tendency_of_water_vapor_mixing_ratio_due_to_mi... dq_micro \n", + "67 tendency_of_water_vapor_mixing_ratio_due_to_mi... dq_turb \n", + "68 tendency_of_aerosol_number_due_to_warm_microph... dna_micro_warm \n", + "69 tendency_of_aerosol_number_due_to_cold_microph... dna_micro_cold \n", + "70 tendency_of_aerosol_number_due_to_mixing dna_turb \n", + "71 tendency_of_ice_number_due_to_heterogeneous_fr... dni_het \n", + "72 tendency_of_ice_number_due_to_secondary_ice_pr... dni_sip \n", + "73 tendency_of_ice_number_due_to_homogeneous_free... dni_hom \n", + "\n", + " units dimensions \\\n", + "0 s – \n", + "1 m – \n", + "2 m – \n", + "3 Pa time \n", + "4 K time \n", + "5 m s-1 time \n", + "6 m time \n", + "7 m time \n", + "8 m time \n", + "9 W m-2 time \n", + "10 W m-2 time \n", + "11 m time \n", + "12 kg m-2 time \n", + "13 kg m-2 time \n", + "14 kg m-2 time \n", + "15 1 time \n", + "16 1 time \n", + "17 1 time \n", + "18 kg m-2 s-1 time \n", + "19 kg m-2 s-1 time \n", + "20 W m-2 time \n", + "21 W m-2 time \n", + "22 W m-2 time \n", + "23 m-2 s-1 time \n", + "24 Pa time, height \n", + "25 m s-1 time, height \n", + "26 m s-1 time, height \n", + "27 kg m-3 time, height \n", + "28 K time, height \n", + "29 kg kg-1 time, height \n", + "30 1 time, height \n", + "31 1 time, height \n", + "32 K time, height \n", + "33 m2 s-2 time, height \n", + "34 m2 s-2 time, height \n", + "35 kg kg-1 time, height \n", + "36 kg kg-1 time, height \n", + "37 kg kg-1 time, height \n", + "38 kg kg-1 time, height \n", + "39 kg kg-1 time, height \n", + "40 kg-1 time, height \n", + "41 kg-1 time, height \n", + "42 kg-1 time, height \n", + "43 kg-1 time, height \n", + "44 kg-1 time, height \n", + "45 kg-1 time, height \n", + "46 kg-1 time, height \n", + "47 kg-1 time, height \n", + "48 kg-1 time, height \n", + "49 kg-1 time, height \n", + "50 m2 s-3 time, height \n", + "51 m2 s-2 time, height \n", + "52 m2 s-2 time, height \n", + "53 m2 s-2 time, height \n", + "54 K m s-1 time, height \n", + "55 K m s-1 time, height \n", + "56 kg kg-1 m s-1 time, height \n", + "57 kg kg-1 m s-1 time, height \n", + "58 1 time, height \n", + "59 kg m-2 s-1 time, height \n", + "60 kg m-2 s-1 time, height \n", + "61 W m-2 time, height \n", + "62 W m-2 time, height \n", + "63 K s-1 time, height \n", + "64 K s-1 time, height \n", + "65 K s-1 time, height \n", + "66 kg kg-1 s-1 time, height \n", + "67 kg kg-1 s-1 time, height \n", + "68 kg-1 s-1 time, height \n", + "69 kg-1 s-1 time, height \n", + "70 kg-1 s-1 time, height \n", + "71 kg-1 s-1 time, height \n", + "72 kg-1 s-1 time, height \n", + "73 kg-1 s-1 time, height \n", + "\n", + " comment (10-min average reported at endpoints, green=minimum) \n", + "0 dimension, seconds since 2020-03-12 22:00:00 \n", + "1 dimension, altitude of mid-level points above ... \n", + "2 dimension, altitude of layer top points above ... \n", + "3 – \n", + "4 – \n", + "5 – \n", + "6 – \n", + "7 – \n", + "8 – \n", + "9 – \n", + "10 – \n", + "11 – \n", + "12 default breakdown to cloud water and rain in a... \n", + "13 – \n", + "14 all ice-phase hydrometeors \n", + "15 fraction of atmospheric columns with total hyd... \n", + "16 scene (all sky); mid-visible, all hydrometeors... \n", + "17 as for optical_depth but cloud droplets only \n", + "18 liquid and ice phase, all hydrometeors \n", + "19 ice phase hydrometeors only \n", + "20 at top of atmosphere \n", + "21 – \n", + "22 – \n", + "23 when using prognostic aerosol; emission only (... \n", + "24 – \n", + "25 – \n", + "26 – \n", + "27 – \n", + "28 – \n", + "29 per kg dry air \n", + "30 relative to liquid \n", + "31 relative to ice \n", + "32 – \n", + "33 resolved only; compute mean values horizontall... \n", + "34 SGS only \n", + "35 scene (all sky) per kg dry air; default breakd... \n", + "36 – \n", + "37 default breakdown to cloud_ice, snow and graup... \n", + "38 – \n", + "39 – \n", + "40 scene (all sky) per kg dry air; default breakd... \n", + "41 – \n", + "42 default breakdown to cloud_ice, snow and graup... \n", + "43 – \n", + "44 – \n", + "45 when using prognostic aerosol; scene (all sky)... \n", + "46 accumulation mode \n", + "47 sea spray mode \n", + "48 per kg dry air where cloud water > 0.01 g/kg; ... \n", + "49 total ice hydrometeors per kg dry air where cl... \n", + "50 total (including numerical diffusion contribut... \n", + "51 total (resolved plus SGS); for resolved compon... \n", + "52 total (resolved plus SGS); for resolved compon... \n", + "53 total (resolved plus SGS); for resolved compon... \n", + "54 total (resolved plus SGS); for resolved compon... \n", + "55 total (resolved plus SGS); include sedimentati... \n", + "56 total (resolved plus SGS); for resolved compon... \n", + "57 total (resolved plus SGS); vapor+all liquid+al... \n", + "58 fraction of cells with cloud water threshold o... \n", + "59 liquid and ice phase, all hydrometeors \n", + "60 – \n", + "61 – \n", + "62 – \n", + "63 – \n", + "64 including net condensation and precipitation \n", + "65 including surface fluxes \n", + "66 including net condensation and precipitation \n", + "67 including surface fluxes \n", + "68 activated and unactivated aerosol (sum over al... \n", + "69 activated and unactivated aerosol (sum over al... \n", + "70 activated and unactivated aerosol (sum over al... \n", + "71 sum of primary ice nucleation due to activatio... \n", + "72 sum of secondary ice formation processes (e.g.... \n", + "73 ice nucleation source due to homogoeneous free... " + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# read list of requested variables\n", + "vars_mean_list = pd.read_excel('https://docs.google.com/spreadsheets/d/1Vl8jYGviet7EtXZuQiitrx4NSkV1x27aJAhxxjBb9zI/export?gid=0&format=xlsx',\n", + " sheet_name='Mean')\n", + "\n", + "pd.set_option('display.max_rows', None)\n", + "vars_mean_list#.iloc[:, :5]" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "aa376605", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
standard_namevariable_idunitsdimensionscomment (10-min instantaneous)
0timetimesdimension, seconds since 2020-03-12 22:00:00
1xxmdimension, grid cell center
2yymdimension, grid cell center
3surface_upward_sensible_heat_fluxhfssW m-2time, x, y
4surface_upward_latent_heat_fluxhflsW m-2time, x, y
5surface_friction_velocityustarm s-1time, x, y
6surface_eastward_windusm s-1time, x, yat 10-m for comparison with SAR satellite meas...
7surface_northward_windvsm s-1time, x, yat 10-m for comparison with SAR satellite meas...
8precipitation_flux_at_surfaceprkg m-2 s-1time, x, yall hydrometeors
9atmosphere_mass_content_of_liquid_waterlwpkg m-2time, x, yall liquid hydrometeors
10atmosphere_mass_content_of_iceiwpkg m-2time, x, yall ice hydrometeors
11atmosphere_optical_thicknessopt1time, x, yall hydrometeors for comparison with VIIRS; mi...
12pseudo-albedoalb1time, x, yopt/(opt+13), where opt = all hydrometeor opti...
13toa_outgoing_longwave_flux_atmospheric_windowolr11Ktime, x, yflux at top-of-atmosphere in window containing...
\n", + "
" + ], + "text/plain": [ + " standard_name variable_id units \\\n", + "0 time time s \n", + "1 x x m \n", + "2 y y m \n", + "3 surface_upward_sensible_heat_flux hfss W m-2 \n", + "4 surface_upward_latent_heat_flux hfls W m-2 \n", + "5 surface_friction_velocity ustar m s-1 \n", + "6 surface_eastward_wind us m s-1 \n", + "7 surface_northward_wind vs m s-1 \n", + "8 precipitation_flux_at_surface pr kg m-2 s-1 \n", + "9 atmosphere_mass_content_of_liquid_water lwp kg m-2 \n", + "10 atmosphere_mass_content_of_ice iwp kg m-2 \n", + "11 atmosphere_optical_thickness opt 1 \n", + "12 pseudo-albedo alb 1 \n", + "13 toa_outgoing_longwave_flux_atmospheric_window olr11 K \n", + "\n", + " dimensions comment (10-min instantaneous) \n", + "0 – dimension, seconds since 2020-03-12 22:00:00 \n", + "1 – dimension, grid cell center \n", + "2 – dimension, grid cell center \n", + "3 time, x, y – \n", + "4 time, x, y – \n", + "5 time, x, y – \n", + "6 time, x, y at 10-m for comparison with SAR satellite meas... \n", + "7 time, x, y at 10-m for comparison with SAR satellite meas... \n", + "8 time, x, y all hydrometeors \n", + "9 time, x, y all liquid hydrometeors \n", + "10 time, x, y all ice hydrometeors \n", + "11 time, x, y all hydrometeors for comparison with VIIRS; mi... \n", + "12 time, x, y opt/(opt+13), where opt = all hydrometeor opti... \n", + "13 time, x, y flux at top-of-atmosphere in window containing... " + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# read list of requested variables\n", + "vars_2d_list = pd.read_excel('https://docs.google.com/spreadsheets/d/1Vl8jYGviet7EtXZuQiitrx4NSkV1x27aJAhxxjBb9zI/export?format=xlsx&gid=1756539842')\n", + "vars_2d_list#.iloc[:, :5]" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "bfb6a0d3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
standard_namevariable_idunitsdimensionscomment (60-min instantaneous, red=required for EMC2)
0timetimesdimension, seconds since 2020-03-12 22:00:00
1xxmdimension, grid cell center
2yymdimension, grid cell center
3heightzfmdimension, altitude of mid-level points above ...
4air_pressurepaPatime, height
5eastward_winduam s-1time, height, x, y
6northward_windvam s-1time, height, x, y
7upward_air_velocitywam s-1time, height, x, y
8air_temperaturetaKtime, height, x, y
9air_dry_densityrhoakg m-3time, height, x, y
10water_vapor_mixing_ratioqvkg kg-1time, height, x, yper kg dry air
11mass_mixing_ratio_of_cloud_liquid_water_in_airqlckg kg-1time, height, x, yper kg dry air; default breakdown to cloud wat...
12mass_mixing_ratio_of_rain_water_in_airqlrkg kg-1time, height, x, y
13mass_mixing_ratio_of_cloud_ice_in_airqickg kg-1time, height, x, ydefault breakdown to cloud_ice, snow and graup...
14mass_mixing_ratio_of_snow_in_airqiskg kg-1time, height, x, y
15mass_mixing_ratio_of_graupel_in_airqigkg kg-1time, height, x, y
16number_of_dry_aerosol_in_airnakg-1time, height, x, yper kg dry air; when using prognostic aerosol
17number_of_cloud_droplets_in_airnlckg-1time, height, x, ywhen using prognostic aerosol
18number_of_rain_droplets_in_airnlrkg-1time, height, x, y
19number_of_cloud_ice_crystals_in_airnickg-1time, height, x, ydefault breakdown to cloud_ice, snow and graup...
20number_of_snow_crystals_in_airniskg-1time, height, x, y
21number_of_graupel_crystals_in_airnigkg-1time, height, x, y
22dissipation_rate_of_turbulent_kinetic_energyepsm2 s-3time, height, x, yincluding numerical diffusion contributions if...
23tendency_of_condensationtend_conds-1time, height, x, ycombined tendencies of cloud liquid and rain w...
24tendency_of_depositiontend_deps-1time, height, x, ytendency of ice mixing ratio due to deposition...
25tendency_of_rimingtend_rims-1time, height, x, ytendency of ice mixing ratio due to riming; su...
\n", + "
" + ], + "text/plain": [ + " standard_name variable_id units \\\n", + "0 time time s \n", + "1 x x m \n", + "2 y y m \n", + "3 height zf m \n", + "4 air_pressure pa Pa \n", + "5 eastward_wind ua m s-1 \n", + "6 northward_wind va m s-1 \n", + "7 upward_air_velocity wa m s-1 \n", + "8 air_temperature ta K \n", + "9 air_dry_density rhoa kg m-3 \n", + "10 water_vapor_mixing_ratio qv kg kg-1 \n", + "11 mass_mixing_ratio_of_cloud_liquid_water_in_air qlc kg kg-1 \n", + "12 mass_mixing_ratio_of_rain_water_in_air qlr kg kg-1 \n", + "13 mass_mixing_ratio_of_cloud_ice_in_air qic kg kg-1 \n", + "14 mass_mixing_ratio_of_snow_in_air qis kg kg-1 \n", + "15 mass_mixing_ratio_of_graupel_in_air qig kg kg-1 \n", + "16 number_of_dry_aerosol_in_air na kg-1 \n", + "17 number_of_cloud_droplets_in_air nlc kg-1 \n", + "18 number_of_rain_droplets_in_air nlr kg-1 \n", + "19 number_of_cloud_ice_crystals_in_air nic kg-1 \n", + "20 number_of_snow_crystals_in_air nis kg-1 \n", + "21 number_of_graupel_crystals_in_air nig kg-1 \n", + "22 dissipation_rate_of_turbulent_kinetic_energy eps m2 s-3 \n", + "23 tendency_of_condensation tend_cond s-1 \n", + "24 tendency_of_deposition tend_dep s-1 \n", + "25 tendency_of_riming tend_rim s-1 \n", + "\n", + " dimensions comment (60-min instantaneous, red=required for EMC2) \n", + "0 – dimension, seconds since 2020-03-12 22:00:00 \n", + "1 – dimension, grid cell center \n", + "2 – dimension, grid cell center \n", + "3 – dimension, altitude of mid-level points above ... \n", + "4 time, height – \n", + "5 time, height, x, y – \n", + "6 time, height, x, y – \n", + "7 time, height, x, y – \n", + "8 time, height, x, y – \n", + "9 time, height, x, y – \n", + "10 time, height, x, y per kg dry air \n", + "11 time, height, x, y per kg dry air; default breakdown to cloud wat... \n", + "12 time, height, x, y – \n", + "13 time, height, x, y default breakdown to cloud_ice, snow and graup... \n", + "14 time, height, x, y – \n", + "15 time, height, x, y – \n", + "16 time, height, x, y per kg dry air; when using prognostic aerosol \n", + "17 time, height, x, y when using prognostic aerosol \n", + "18 time, height, x, y – \n", + "19 time, height, x, y default breakdown to cloud_ice, snow and graup... \n", + "20 time, height, x, y – \n", + "21 time, height, x, y – \n", + "22 time, height, x, y including numerical diffusion contributions if... \n", + "23 time, height, x, y combined tendencies of cloud liquid and rain w... \n", + "24 time, height, x, y tendency of ice mixing ratio due to deposition... \n", + "25 time, height, x, y tendency of ice mixing ratio due to riming; su... " + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vars_3d_list = pd.read_excel('https://docs.google.com/spreadsheets/d/1Vl8jYGviet7EtXZuQiitrx4NSkV1x27aJAhxxjBb9zI/export?format=xlsx&gid=1233994833')\n", + "vars_3d_list#.iloc[:, :5]" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "2579c413", + "metadata": {}, "outputs": [], "source": [ - "Output_statistic = {\n", - " 'ps': { 'std_name': 'surface_pressure', 'var_id': 'ps', 'units': 'Pa', 'dim': 'time'},\n", - " 'ts': { 'std_name': 'surface_temperature', 'var_id': 'ts', 'units': 'K' , 'dim': 'time'},\n", - " 'ustar': { 'std_name': 'surface_friction_velocity', 'var_id': 'ustar', 'units': 'm s-1', 'dim': 'time'},\n", - " 'z0' : { 'std_name': 'surface_roughness_length_for_momentum_in_air', 'var_id': 'z0', 'units': 'm', 'dim': 'time'},\n", - " 'z0h': { 'std_name': 'surface_roughness_length_for_heat_in_air', 'var_id': 'z0h', 'units': 'm', 'dim': 'time'},\n", - " 'z0q': { 'std_name': 'surface_roughness_length_for_humidity_in_air', 'var_id': 'z0q', 'units': 'm', 'dim': 'time'},\n", - " 'hfss': { 'std_name': 'surface_upward_sensible_heat_flux', 'var_id': 'hfss', 'units': 'W m-2', 'dim': 'time'},\n", - " 'hfls': { 'std_name': 'surface_upward_latent_heat_flux', 'var_id': 'hfls', 'units': 'W m-2', 'dim': 'time'},\n", - " 'ol' : { 'std_name': 'obukhov_length', 'var_id': 'ol', 'units': 'm', 'dim': 'time'},\n", - " 'lwpc': { 'std_name': 'atmosphere_mass_content_of_liquid_cloud_water', 'var_id': 'lwpc', 'units': 'kg m-2', 'dim': 'time'},\n", - " 'lwpr': { 'std_name': 'atmosphere_mass_content_of_rain_water', 'var_id': 'lwpr', 'units': 'kg m-2', 'dim': 'time'},\n", - " 'iwp' : { 'std_name': 'atmosphere_mass_content_of_ice_water', 'var_id': 'iwp', 'units': 'kg m-2', 'dim': 'time'},\n", - " 'clt' : { 'std_name': 'cloud_area_fraction', 'var_id': 'clt', 'units': '1', 'dim': 'time'},\n", - " 'od' : { 'std_name': 'optical_depth', 'var_id': 'od', 'units': '1', 'dim': 'time'},\n", - " 'odlc' : { 'std_name': 'optical_depth_of_liquid_cloud', 'var_id': 'odlc', 'units': '1', 'dim': 'time'},\n", - " 'pr' : { 'std_name': 'precipitation_flux_at_surface', 'var_id': 'pr', 'units': 'kg m-2 s-1', 'dim': 'time'},\n", - " 'pri' : { 'std_name': 'precipitation_flux_at_surface_in_ice_phase', 'var_id': 'pri', 'units': 'kg m-2 s-1', 'dim': 'time'},\n", - " 'rlut' : { 'std_name': 'toa_outgoing_longwave_flux', 'var_id': 'rlut', 'units': 'W m-2', 'dim': 'time'},\n", - " 'rlds' : { 'std_name': 'surface_downwelling_longwave_flux', 'var_id': 'rlds', 'units': 'W m-2', 'dim': 'time'},\n", - " 'rlus' : { 'std_name': 'surface_upwelling_longwave_flux', 'var_id': 'rlus', 'units': 'W m-2', 'dim': 'time'},\n", - " 'ssaf' : { 'std_name': 'surface_sea_spray_number_flux', 'var_id': 'ssaf', 'units': 'm-2 s-1', 'dim': 'time'},\n", - " 'pa' : { 'std_name': 'air_pressure', 'var_id': 'pa', 'units': 'Pa', 'dim': 'time, height'},\n", - " 'ua' : { 'std_name': 'eastward_wind', 'var_id': 'ua', 'units': 'm s-1', 'dim': 'time, height'},\n", - " 'va' : { 'std_name': 'northward_wind', 'var_id': 'va', 'units': 'm s-1', 'dim': 'time, height'},\n", - " 'rhoa' : { 'std_name': 'air_dry_density', 'var_id': 'rhoa', 'units': 'kg m-3', 'dim': 'time, height'},\n", - " 'ta' : { 'std_name': 'air_temperature', 'var_id': 'ta', 'units': 'K', 'dim': 'time, height'},\n", - " 'qv' : { 'std_name': 'water_vapor_mixing_ratio', 'var_id': 'qv', 'units': 'kg kg-1', 'dim': 'time, height'},\n", - " 'hur' : { 'std_name': 'relative_humidity', 'var_id': 'hur', 'units': '1', 'dim': 'time, height'},\n", - " 'huri' : { 'std_name': 'relative_humidity_over_ice', 'var_id': 'huri', 'units': '1', 'dim': 'time, height'},\n", - " 'theta' : { 'std_name': 'air_potential_temperature', 'var_id': 'theta', 'units': 'K', 'dim': 'time, height'},\n", - " 'tke_res': { 'std_name': 'specific_turbulent_kinetic_energy_resolved', 'var_id': 'tke_res', 'units': 'm2 s-2', 'dim': 'time, height'},\n", - " 'tke_sgs': { 'std_name': 'specific_turbulent_kinetic_energy_sgs', 'var_id': 'tke_sgs', 'units': 'm2 s-2', 'dim': 'time, height'},\n", - " 'qlc': { 'std_name': 'mass_mixing_ratio_of_cloud_liquid_water_in_air','var_id': 'qlc', 'units': 'kg kg-1', 'dim': 'time, height'},\n", - " 'qlr': { 'std_name': 'mass_mixing_ratio_of_rain_water_in_air', 'var_id': 'qlr', 'units': 'kg kg-1', 'dim': 'time, height'},\n", - " 'qic': { 'std_name': 'mass_mixing_ratio_of_cloud_ice_in_air', 'var_id': 'qic', 'units': 'kg kg-1', 'dim': 'time, height'},\n", - " 'qis': { 'std_name': 'mass_mixing_ratio_of_snow_in_air', 'var_id': 'qis', 'units': 'kg kg-1', 'dim': 'time, height'},\n", - " 'qig': { 'std_name': 'mass_mixing_ratio_of_graupel_in_air', 'var_id': 'qig', 'units': 'kg kg-1', 'dim': 'time, height'},\n", - " 'nlc': { 'std_name': 'number_of_liquid_cloud_droplets_in_air', 'var_id': 'nlc', 'units': 'kg-1', 'dim': 'time, height'},\n", - " 'nlr': { 'std_name': 'number_of_rain_drops_in_air', 'var_id': 'nlr', 'units': 'kg-1', 'dim': 'time, height'},\n", - " 'nic': { 'std_name': 'number_of_cloud_ice_crystals_in_air', 'var_id': 'nic', 'units': 'kg-1', 'dim': 'time, height'},\n", - " 'nis': { 'std_name': 'number_of_snow_crystals_in_air', 'var_id': 'nis', 'units': 'kg-1', 'dim': 'time, height'},\n", - " 'nig': { 'std_name': 'number_of_graupel_crystals_in_air', 'var_id': 'nig', 'units': 'kg-1', 'dim': 'time, height'},\n", - " 'na1': { 'std_name': 'number_of_total_aerosol_mode1', 'var_id': 'na1', 'units': 'kg-1', 'dim': 'time, height'},\n", - " 'na2': { 'std_name': 'number_of_total_aerosol_mode2', 'var_id': 'na2', 'units': 'kg-1', 'dim': 'time, height'},\n", - " 'na3': { 'std_name': 'number_of_total_aerosol_mode3', 'var_id': 'na3', 'units': 'kg-1', 'dim': 'time, height'},\n", - " 'nlcic': { 'std_name': 'number_of_liquid_cloud_droplets_in_cloud', 'var_id': 'nlcic', 'units': 'kg-1', 'dim': 'time, height'},\n", - " 'niic' : { 'std_name': 'number_of_ice_crystals_in_cloud', 'var_id': 'niic', 'units': 'kg-1', 'dim': 'time, height'}\n", + "Output_Mean = {row['variable_id']: {\n", + " 'std_name': str(row['standard_name']) if pd.notna(row['standard_name']) else '',\n", + " 'var_id': str(row['variable_id']),\n", + " 'units': str(row['units']) if pd.notna(row['units']) else '',\n", + " 'dim': str(row['dimensions']) if pd.notna(row['dimensions']) else ''\n", + " }\n", + " for _, row in vars_mean_list.iterrows()\n", + " if pd.notna(row['variable_id'])\n", "}\n", "\n", - "\n", - "Output_2D = {\n", - " 'time' : {'std_name': 'time' , 'var_id': 'time' , 'units': 's'},\n", - " 'x' : {'std_name': 'x' , 'var_id': 'x' , 'units': 'm'},\n", - " 'y' : {'std_name': 'y' , 'var_id': 'y' , 'units': 'm'},\n", - " 'hfss' : {'std_name': 'surface_upward_sensible_heat_flux' , 'var_id': 'hfss' , 'units': 'W m-2' , 'dimensions': ['time', 'x', 'y']},\n", - " 'hfls' : {'std_name': 'surface_upward_latent_heat_flux' , 'var_id': 'hfls' , 'units': 'W m-2' , 'dimensions': ['time', 'x', 'y']},\n", - " 'ustar': {'std_name': 'surface_friction_velocity' , 'var_id': 'ustar' , 'units': 'm s-1' , 'dimensions': ['time', 'x', 'y']},\n", - " 'us' : {'std_name': 'surface_eastward_wind' , 'var_id': 'us' , 'units': 'm s-1' , 'dimensions': ['time', 'x', 'y']},\n", - " 'vs' : {'std_name': 'surface_northward_wind' , 'var_id': 'vs' , 'units': 'm s-1' , 'dimensions': ['time', 'x', 'y']},\n", - " 'pr' : {'std_name': 'precipitation_flux_at_surface' , 'var_id': 'pr' , 'units': 'kg m-2 s-1' , 'dimensions': ['time', 'x', 'y']},\n", - " 'lwp' :{'std_name': 'atmosphere_mass_content_of_liquid_water' , 'var_id': 'lwp' , 'units': 'kg m-2' , 'dimensions': ['time', 'x', 'y']},\n", - " 'iwp' :{'std_name': 'atmosphere_mass_content_of_ice' , 'var_id': 'iwp' , 'units': 'kg m-2' , 'dimensions': ['time', 'x', 'y']},\n", - " 'opt' :{'std_name': 'atmosphere_optical_thickness' , 'var_id': 'opt' , 'units': ' ' , 'dimensions': ['time', 'x', 'y']},\n", - " 'alb' :{'std_name': 'pseudo-albedo' , 'var_id': 'alb' , 'units': ' ' , 'dimensions': ['time', 'x', 'y']},\n", - " 'olr11':{'std_name': 'toa_outgoing_longwave_flux_atmospheric_window', 'var_id': 'olr11' , 'units': 'K' , 'dimensions': ['time', 'x', 'y']}\n", + "Output_2D = {row['variable_id']: {\n", + " 'std_name': str(row['standard_name']) if pd.notna(row['standard_name']) else '',\n", + " 'var_id': str(row['variable_id']),\n", + " 'units': str(row['units']) if pd.notna(row['units']) else '',\n", + " 'dim': str(row['dimensions']) if pd.notna(row['dimensions']) else ''\n", + " }\n", + " for _, row in vars_2d_list.iterrows()\n", + " if pd.notna(row['variable_id'])\n", "}\n", "\n", - "Output_3D = {\n", - " 'time': {'std_name': 'time' , 'var_id': 'time', 'units': 's'},\n", - " 'x' : {'std_name': 'x' , 'var_id': 'x' , 'units': 'm'},\n", - " 'y' : {'std_name': 'y' , 'var_id': 'y' , 'units': 'm'},\n", - " 'zf' : {'std_name': 'height' , 'var_id': 'zf' , 'units': 'm', 'dimensions': ['time']},\n", - " 'pa' : {'std_name': 'air_pressure' , 'var_id': 'pa' , 'units': 'Pa', 'dimensions': ['time', 'height']},\n", - " 'ua' : {'std_name': 'eastward_wind' , 'var_id': 'ua' , 'units': 'm s^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'va' : {'std_name': 'northward_wind' , 'var_id': 'va' , 'units': 'm s^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'wa' : {'std_name': 'upward_air_velocity' , 'var_id': 'wa' , 'units': 'm s^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'ta' : {'std_name': 'air_temperature' , 'var_id': 'ta' , 'units': 'K', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'rhoa': {'std_name': 'air_dry_density' , 'var_id': 'rhoa', 'units': 'kg m^-3', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'qv' : {'std_name': 'water_vapor_mixing_ratio' , 'var_id': 'qv', 'units': 'kg kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'qlc' : {'std_name': 'mass_mixing_ratio_of_cloud_liquid_water_in_air' , 'var_id': 'qlc', 'units': 'kg kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'qlr' : {'std_name': 'mass_mixing_ratio_of_rain_water_in_air' , 'var_id': 'qlr', 'units': 'kg kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'qic' : {'std_name': 'mass_mixing_ratio_of_cloud_ice_in_air' , 'var_id': 'qic', 'units': 'kg kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'qis' : {'std_name': 'mass_mixing_ratio_of_snow_in_air' , 'var_id': 'qis', 'units': 'kg kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'qig' : {'std_name': 'mass_mixing_ratio_of_graupel_in_air' , 'var_id': 'qig', 'units': 'kg kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'na' : {'std_name': 'number_of_dry_aerosol_in_air' , 'var_id': 'na', 'units': 'kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'nlc' : {'std_name': 'number_of_cloud_droplets_in_air' , 'var_id': 'nlc', 'units': 'kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'nlr' : {'std_name': 'number_of_rain_droplets_in_air' , 'var_id': 'nlr', 'units': 'kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'nic' : {'std_name': 'number_of_cloud_ice_crystals_in_air' , 'var_id': 'nic', 'units': 'kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'nis' : {'std_name': 'number_of_snow_crystals_in_air' , 'var_id': 'nis', 'units': 'kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'nig' : {'std_name': 'number_of_graupel_crystals_in_air' , 'var_id': 'nig', 'units': 'kg^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'eps' : {'std_name': 'dissipation_rate_of_turbulent_kinetic_energy' , 'var_id': 'eps', 'units': 'm^2 s^-3', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'vmlc': {'std_name': 'mass_weighted_fall_speed_of_liquid_cloud_water' , 'var_id': 'vmlc', 'units': 'm s^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'vmlr': {'std_name': 'mass_weighted_fall_speed_of_rain' , 'var_id': 'vmlr', 'units': 'm s^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'vmic': {'std_name': 'mass_weighted_fall_speed_of_ice_cloud' , 'var_id': 'vmic', 'units': 'm s^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'vmis': {'std_name': 'mass_weighted_fall_speed_of_snow' , 'var_id': 'vmis', 'units': 'm s^-1', 'dimensions': ['time', 'height', 'x', 'y']},\n", - " 'vmig': {'std_name': 'mass_weighted_fall_speed_of_graupel' , 'var_id': 'vmig', 'units': 'm s^-1', 'dimensions': ['time', 'height', 'x', 'y']}\n", - "}\n", - "\n" + "Output_3D = {row['variable_id']: {\n", + " 'std_name': str(row['standard_name']) if pd.notna(row['standard_name']) else '',\n", + " 'var_id': str(row['variable_id']),\n", + " 'units': str(row['units']) if pd.notna(row['units']) else '',\n", + " 'dim': str(row['dimensions']) if pd.notna(row['dimensions']) else ''\n", + " }\n", + " for _, row in vars_3d_list.iterrows()\n", + " if pd.notna(row['variable_id'])\n", + "}" ] }, { "cell_type": "code", - "execution_count": 15, - "metadata": { - "metadata": {} - }, + "execution_count": 9, + "id": "cb61130e", + "metadata": {}, "outputs": [], "source": [ - "def convert_TS_to_xarray(TS_output):\n", - "\n", - " data=np.genfromtxt(TS_output, skip_header=1)\n", - "\n", - " # Read the variable names from the first line\n", - " with open(TS_output, 'r') as file:\n", - " header = file.readline().strip()\n", - " variable_names = header.split()[2:] # Exclude the # symbol and the 'time'\n", - "\n", - " # Extract time and data for each variable\n", - " time = data[:, 0]\n", - " variables_data = data[:,1:]\n", - "\n", - " # Create an xarray dataset\n", - " ds = xr.Dataset()\n", - "\n", - " # Add time as a dimension\n", - " ds['time'] = time\n", - "\n", - " # Add variables as data variables\n", - " for ii, var_name in enumerate(variable_names):\n", - " ds[var_name] = (['time'], variables_data[:,ii])\n", - "\n", - " file.close()\n", - "\n", - " return(ds)\n", - "\n", - "\n", "def Output_add_attributes(output_data,output_name,mixed_phase):\n", " \n", " if mixed_phase:\n", "\n", - " Output_statistic_attr={'title': 'Mean output for '+output_name,\n", + " Output_Mean_attr={'title': 'Mean output for '+output_name,\n", " 'reference': 'COMBLE',\n", " 'author': 'Alejandro Baro Perez (alejandro.baro.perez@misu.su.se)',\n", - " 'version': 'Created on 2026-05-27',\n", + " 'version': 'Created on 2026-06-18',\n", " 'format_version': 'DEPHY SCM format version 1',}\n", " \n", " else:\n", " \n", - " Output_statistic_attr={'case': 'COMBLE_CAO','title': 'Mean output for '+output_name,\n", + " Output_Mean_attr={'case': 'COMBLE_CAO','title': 'Mean output for '+output_name,\n", " 'reference': 'COMBLE',\n", " 'author': 'Alejandro Baro Perez (alejandro.baro.perez@misu.su.se)',\n", - " 'version': 'Created on 2026-05-27',\n", + " 'version': 'Created on 2026-06-18',\n", " 'format_version': 'DEPHY SCM format version 1',} \n", " \n", " \n", - " output_data.attrs=Output_statistic_attr\n", + " output_data.attrs=Output_Mean_attr\n", " \n", " return(output_data)\n", "\n", @@ -250,107 +1537,128 @@ " MIMICA_name=['SST','U_star', 'Z0_m','z0_h','SHF','LHF','L_MO','OLR', 'Surface_LW_up','Surface_LW_down']\n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", " Statistical_output[dephy]=MIMICA_TS[mimica]\n", - " Statistical_output[dephy].attrs['standard_name']= Output_statistic[dephy]['std_name'] \n", - " Statistical_output[dephy].attrs['units']=Output_statistic[dephy]['units'] \n", + " Statistical_output[dephy].attrs['standard_name']= Output_Mean[dephy]['std_name'] \n", + " Statistical_output[dephy].attrs['units']=Output_Mean[dephy]['units'] \n", " \n", " # Water paths\n", " DEPHY_name=['lwpc','lwpr','iwp']\n", " MIMICA_name=['LWPc','LWPr', 'IWP'] \n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", " Statistical_output[dephy]=MIMICA_TS[mimica]\n", - " Statistical_output[dephy].attrs['standard_name']= Output_statistic[dephy]['std_name'] \n", - " Statistical_output[dephy].attrs['units']=Output_statistic[dephy]['units'] \n", + " Statistical_output[dephy].attrs['standard_name']= Output_Mean[dephy]['std_name'] \n", + " Statistical_output[dephy].attrs['units']=Output_Mean[dephy]['units'] \n", " \n", " #Cloud area fraction\n", " Statistical_output['clt']=MIMICA_TS['C_COL']\n", - " Statistical_output['clt'].attrs['standard_name']= Output_statistic['clt']['std_name'] \n", - " Statistical_output['clt'].attrs['units']=Output_statistic['clt']['units'] \n", + " Statistical_output['clt'].attrs['standard_name']= Output_Mean['clt']['std_name'] \n", + " Statistical_output['clt'].attrs['units']=Output_Mean['clt']['units'] \n", " \n", " #Optical depths\n", " Statistical_output['od'] =(MIMICA_surf['OPTC']+MIMICA_surf['OPTI']+MIMICA_surf['OPTR']).mean(dim=('Y','X'))\n", - " Statistical_output['od'].attrs['standard_name']= Output_statistic['od']['std_name'] \n", - " Statistical_output['od'].attrs['units']=Output_statistic['od']['units']\n", + " Statistical_output['od'].attrs['standard_name']= Output_Mean['od']['std_name'] \n", + " Statistical_output['od'].attrs['units']=Output_Mean['od']['units']\n", " \n", " Statistical_output['odlc'] =MIMICA_surf['OPTC'].mean(dim=('Y','X'))\n", - " Statistical_output['odlc'].attrs['standard_name']= Output_statistic['odlc']['std_name'] \n", - " Statistical_output['odlc'].attrs['units']=Output_statistic['odlc']['units']\n", + " Statistical_output['odlc'].attrs['standard_name']= Output_Mean['odlc']['std_name'] \n", + " Statistical_output['odlc'].attrs['units']=Output_Mean['odlc']['units']\n", " \n", " # Surface flux of aerosols MIMICA\n", " if 'Surf_naer_flux' in MIMICA_surf:\n", " Statistical_output['ssaf']=MIMICA_surf['Surf_naer_flux'].mean(dim=('Y','X'))\n", - " Statistical_output['ssaf'].attrs['standard_name']= Output_statistic['ssaf']['std_name'] \n", - " Statistical_output['ssaf'].attrs['units']= Output_statistic['ssaf']['units']\n", + " Statistical_output['ssaf'].attrs['standard_name']= Output_Mean['ssaf']['std_name'] \n", + " Statistical_output['ssaf'].attrs['units']= Output_Mean['ssaf']['units']\n", " \n", " \n", " # U,V,temperature,potential temperature,water vapor mixing fraction(ratio)\n", - " DEPHY_name=['pa', 'ua', 'va', 'rhoa','ta','theta','tke_res','tke_sgs']\n", - " MIMICA_name=['P_tot','U', 'V','RHO','T','PT' , 'TKE' , 'TKE_sgs']\n", + " DEPHY_name=['pa', 'ua', 'va','ta','theta','tke_res','tke_sgs']\n", + " MIMICA_name=['P_tot','U', 'V', 'T','PT' , 'TKE' , 'TKE_sgs']\n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", " Statistical_output[dephy]=MIMICA_prof[mimica]\n", - " Statistical_output[dephy].attrs['standard_name']= Output_statistic[dephy]['std_name'] \n", - " Statistical_output[dephy].attrs['units']= Output_statistic[dephy]['units'] \n", + " Statistical_output[dephy].attrs['standard_name']= Output_Mean[dephy]['std_name'] \n", + " Statistical_output[dephy].attrs['units']= Output_Mean[dephy]['units'] \n", + "\n", + " # Dry air density is calculated from MIMICA full density and the total water mixing ratio :\n", + " RHO_dry= MIMICA_prof['RHO']/(1+MIMICA_prof['Qt'])\n", + " Statistical_output['rhoa']=RHO_dry\n", + " Statistical_output['rhoa'].attrs['standard_name']= Output_Mean['rhoa']['std_name'] \n", + " Statistical_output['rhoa'].attrs['units']= Output_Mean['rhoa']['units']\n", + "\n", + " # Vertical velocity variance\n", + " Statistical_output['w2']=MIMICA_prof['W_var']\n", + " Statistical_output['w2'].attrs['standard_name']= Output_Mean['w2']['std_name'] \n", + " Statistical_output['w2'].attrs['units']= Output_Mean['w2']['units']\n", " \n", - " ## Precipitation flux. Change from precipitation rate (MIMICA) to precipitation flux\n", + " ## Precipitation flux at surface. Change from precipitation rate (MIMICA) to precipitation flux\n", " #Considering that\n", - " # density of water = 997 kg/m3\n", - " # density of ice = 917 kg/m3 \n", - " # precipitation rates in MIMICA are given in = mm/d = 1e-3/86400 [m/s]\n", - " # Mulitplying the density of water or ice by the precipitation rates in MIMICA we can get the precipitation fluxes\n", - " # in units [kg m-2 s-1]\n", - " # Then precipitation rates in MIMICA should be multiplied by \n", - " # a factor = 0.997/86400 if water\n", - " # a factor = 0.917/86400 if ice\n", - " \n", - " water_factor= 0.997/86400\n", - " ice_factor= 0.917/86400\n", + " water_factor= 1./86400\n", + " ice_factor= 1./86400\n", " \n", + "\n", " DEPHY_name=['pr','pri']\n", " MIMICA_name=['R_rate','R_ice_rate']\n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", " if mixed_phase:\n", " #Assuming that the liquid phase precipitation in negligible in the mixed phase case\n", - " Statistical_output[dephy]=ice_factor*MIMICA_TS[mimica] \n", - " else:\n", - " Statistical_output[dephy]=water_factor*MIMICA_TS[mimica] \n", - " \n", - " Statistical_output[dephy].attrs['standard_name']= Output_statistic[dephy]['std_name']\n", - " Statistical_output[dephy].attrs['units']= Output_statistic[dephy]['units'] \n", - " \n", + " Statistical_output['pri']=ice_factor*MIMICA_TS['R_ice_rate']\n", + " Statistical_output['pri'].attrs['standard_name']= Output_Mean[dephy]['std_name']\n", + " Statistical_output['pri'].attrs['units']= Output_Mean[dephy]['units']\n", + "\n", + " Statistical_output['pr']=water_factor*MIMICA_TS['R_rate'] \n", + " Statistical_output['pr'].attrs['standard_name']= Output_Mean[dephy]['std_name']\n", + " Statistical_output['pr'].attrs['units']= Output_Mean[dephy]['units'] \n", + "\n", + " #Precipitation flux in air in ice phase (considering the fall speed of the hydrometeors and the mixing ratio of the hydrometeors in air)\n", + " if mixed_phase:\n", + " Statistical_output['prfi']=MIMICA_prof['Qi']*MIMICA_prof['Vpi']+MIMICA_prof['Qs']*MIMICA_prof['Vps']+MIMICA_prof['Qg']*MIMICA_prof['Vpg']\n", + " Statistical_output['prfi'].attrs['standard_name']= Output_Mean['prfi']['std_name'] \n", + " Statistical_output['prfi'].attrs['units']= Output_Mean['prfi']['units']\n", + "\n", + " #Precipitation flux in air (considering the fall speed of the hydrometeors and the mixing ratio of the hydrometeors in air) \n", + " Statistical_output['prf']=Statistical_output['prfi']+ MIMICA_prof['Vpc']*MIMICA_prof['Qc']+MIMICA_prof['Qr']*MIMICA_prof['Vpr'] \n", + " else:\n", + " Statistical_output['prf']=MIMICA_prof['Vpc']*MIMICA_prof['Qc']+MIMICA_prof['Qr']*MIMICA_prof['Vpr']\n", + "\n", + " Statistical_output['prf'].attrs['standard_name']= Output_Mean['prf']['std_name'] \n", + " Statistical_output['prf'].attrs['units']= Output_Mean['prf']['units'] \n", + "\n", + "\n", " # Relative humidity, and relative humidity over ice:\n", " DEPHY_name=['hur','huri']\n", " MIMICA_name=['RH','RHi'] \n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", " Statistical_output[dephy]=1e-2*MIMICA_prof[mimica]\n", - " Statistical_output[dephy].attrs['standard_name']= Output_statistic[dephy]['std_name']\n", - " Statistical_output[dephy].attrs['units']= Output_statistic[dephy]['units'] \n", + " Statistical_output[dephy].attrs['standard_name']= Output_Mean[dephy]['std_name']\n", + " Statistical_output[dephy].attrs['units']= Output_Mean[dephy]['units'] \n", "\n", " # Mixing fraction from MIMICA are directly mass mixing ratio in DEPHY\n", " DEPHY_name=[ 'qv','qlc','qlr','qic','qis','qig']\n", - " MIMICA_name=['Qv','Qc', 'Qr', 'Qi', 'Qs', 'Qg']\n", + " MIMICA_name=['Qv','Qc', 'Qr','Qi', 'Qs', 'Qg']\n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", " if mimica in MIMICA_prof:\n", - " Statistical_output[dephy]=MIMICA_prof[mimica]/MIMICA_prof['RHO']\n", - " Statistical_output[dephy].attrs['standard_name']= Output_statistic[dephy]['std_name']\n", - " Statistical_output[dephy].attrs['units']= Output_statistic[dephy]['units'] \n", + " Statistical_output[dephy]=MIMICA_prof[mimica]/RHO_dry\n", + " Statistical_output[dephy].attrs['standard_name']= Output_Mean[dephy]['std_name']\n", + " Statistical_output[dephy].attrs['units']= Output_Mean[dephy]['units'] \n", + "\n", "\n", " # Hydrometeors number density: \n", " DEPHY_name=['nlc','nlr','nic','nis','nig']\n", " MIMICA_name=['Nc','Nr','Ni','Ns','Ng'] \n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", " if mimica in MIMICA_prof:\n", - " Statistical_output[dephy]=MIMICA_prof[mimica]/MIMICA_prof['RHO']\n", - " Statistical_output[dephy].attrs['standard_name']= Output_statistic[dephy]['std_name'] \n", - " Statistical_output[dephy].attrs['units']= Output_statistic[dephy]['units'] \n", + " Statistical_output[dephy]=MIMICA_prof[mimica]/RHO_dry\n", + " Statistical_output[dephy].attrs['standard_name']= Output_Mean[dephy]['std_name'] \n", + " Statistical_output[dephy].attrs['units']= Output_Mean[dephy]['units'] \n", " \n", - " # Hydrometeors number density in cloud:\n", + " # Hydrometeors number density in cloud:\n", " DEPHY_name=['nlcic','niic']\n", " MIMICA_name=['Nc','Ni'] \n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", " if mimica in MIMICA_prof_cl:\n", " #Statistical_output[dephy]=MIMICA_prof_cl[mimica]/MIMICA_prof_cl['RHO']\n", - " Statistical_output[dephy]=save_division(MIMICA_prof_cl[mimica],MIMICA_prof_cl['RHO'])\n", - " Statistical_output[dephy].attrs['standard_name']= Output_statistic[dephy]['std_name'] \n", - " Statistical_output[dephy].attrs['units']= Output_statistic[dephy]['units'] \n", + " RHO_dry_cl=MIMICA_prof_cl['RHO']/(1+MIMICA_prof_cl['Qt'])\n", + " Statistical_output[dephy]=save_division(MIMICA_prof_cl[mimica],RHO_dry_cl)\n", + " Statistical_output[dephy].attrs['standard_name']= Output_Mean[dephy]['std_name'] \n", + " Statistical_output[dephy].attrs['units']= Output_Mean[dephy]['units'] \n", "\n", " # Number of total aerosol in air #For later !activated + unactivated???\n", " if 'N_AERO1' in MIMICA_prof:\n", @@ -358,7 +1666,7 @@ " MIMICA_name=['N_AERO1','N_AERO2','N_AERO3']\n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", " Statistical_output[dephy]=MIMICA_prof[mimica]\n", - " Statistical_output[dephy].attrs['units']= Output_statistic[dephy]['units']\n", + " Statistical_output[dephy].attrs['units']= Output_Mean[dephy]['units']\n", "\n", " # Renaming vertical coordinate \n", " Statistical_output=Statistical_output.rename({'Z': 'zf'})\n", @@ -394,8 +1702,11 @@ " D2_output[dephy].attrs['units']= Output_2D[dephy]['units'] \n", " \n", " # Precipitation flux. Change from precipitation rate (MIMICA) to precipitation flux\n", - " water_factor= 0.997/86400\n", - " ice_factor= 0.917/86400\n", + " #water_factor= 0.997/86400\n", + " #ice_factor= 0.917/86400\n", + "\n", + " water_factor= 1./86400\n", + " ice_factor= 1./86400\n", " \n", " if mixed_phase:\n", " D2_output['pr']=ice_factor*MIMICA_surf['R_rate']\n", @@ -446,55 +1757,44 @@ " D3_output = xr.Dataset()\n", "\n", " # U,V,temperature,potential temperature,water vapor mixing fraction(ratio)\n", - " DEPHY_name=[ 'pa','ua','va','wa','ta','rhoa']\n", - " MIMICA_name=['P_tot','U', 'V','W', 'T','RHO']\n", + " DEPHY_name=[ 'pa','ua','va','wa','ta']\n", + " MIMICA_name=['P_tot','U', 'V','W', 'T']\n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", " D3_output[dephy]=MIMICA_3D[mimica]\n", " D3_output[dephy].attrs['standard_name']= Output_3D[dephy]['std_name'] \n", " D3_output[dephy].attrs['units']= Output_3D[dephy]['units'] \n", + "\n", + " RHO_dry= MIMICA_3D['RHO']/(1+MIMICA_3D['Qt'])\n", + " D3_output['rhoa']=RHO_dry\n", + " D3_output['rhoa'].attrs['standard_name']= Output_3D['rhoa']['std_name'] \n", + " D3_output['rhoa'].attrs['units']= Output_3D['rhoa']['units']\n", " \n", " # Mixing fraction from MIMICA are directly mass mixing ratio in DEPHY\n", - " DEPHY_name=[ 'qv','qlc','qlr']\n", - " MIMICA_name=['Qv','Qc', 'Qr' ]\n", + " DEPHY_name=[ 'qv','qlc','qlr','qic','qis','qig']\n", + " MIMICA_name=['Qv','Qc', 'Qr','Qi', 'Qs', 'Qg' ]\n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", - " D3_output[dephy]=MIMICA_3D[mimica]\n", - " D3_output[dephy].attrs['standard_name']= Output_3D[dephy]['std_name']\n", - " D3_output[dephy].attrs['units']= Output_3D[dephy]['units'] \n", - " \n", - " # Mixing fraction from MIMICA are directly mass mixing ratio in DEPHY [ice phase]\n", - " if 'Qi' in MIMICA_3D:\n", - " DEPHY_name=[ 'qic','qis','qig']\n", - " MIMICA_name=['Qi', 'Qs', 'Qg' ]\n", - " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", - " D3_output[dephy]=MIMICA_3D[mimica]\n", + " if mimica in MIMICA_3D:\n", + " D3_output[dephy]=MIMICA_3D[mimica]/RHO_dry\n", " D3_output[dephy].attrs['standard_name']= Output_3D[dephy]['std_name']\n", " D3_output[dephy].attrs['units']= Output_3D[dephy]['units'] \n", - " \n", + " \n", " # Hydrometeors number density: #Question here\n", - " DEPHY_name=['nlc','nlr']\n", - " MIMICA_name=['Nc','Nr'] \n", + " DEPHY_name=['nlc','nlr','nic','nis','nig']\n", + " MIMICA_name=['Nc','Nr','Ni','Ns','Ng'] \n", " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", - " D3_output[dephy]=MIMICA_3D[mimica]\n", - " D3_output[dephy].attrs['standard_name']= Output_3D[dephy]['std_name'] \n", - " D3_output[dephy].attrs['units']= Output_3D[dephy]['units'] \n", - " \n", - " # Hydrometeors number density (ice phase) \n", - " if 'Ni' in MIMICA_3D: \n", - " DEPHY_name=['nic','nis','nig']\n", - " MIMICA_name=['Ni','Ns','Ng'] \n", - " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", - " D3_output[dephy]=MIMICA_3D[mimica]\n", - " D3_output[dephy].attrs['standard_name']= Output_3D[dephy]['std_name'] \n", + " if mimica in MIMICA_3D:\n", + " D3_output[dephy]=MIMICA_3D[mimica]/RHO_dry\n", + " D3_output[dephy].attrs['standard_name']= Output_3D[dephy]['std_name'] \n", " D3_output[dephy].attrs['units']= Output_3D[dephy]['units'] \n", - " \n", + " \n", " #Check these variables. Are they mass weighted? \n", - " DEPHY_name=[ 'vmlc','vmlr','vmic','vmis','vmig']\n", - " MIMICA_name=[ 'Vpc','Vpr','Vpi','Vps','Vpg']\n", - " for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", - " if mimica in MIMICA_3D:\n", - " D3_output[dephy]=MIMICA_3D[mimica]\n", - " D3_output[dephy].attrs['standard_name']= Output_3D[dephy]['std_name']\n", - " D3_output[dephy].attrs['units']= Output_3D[dephy]['units'] \n", + " #DEPHY_name=[ 'vmlc','vmlr','vmic','vmis','vmig']\n", + " #MIMICA_name=[ 'Vpc','Vpr','Vpi','Vps','Vpg']\n", + " #for dephy,mimica in zip(DEPHY_name,MIMICA_name):\n", + " # if mimica in MIMICA_3D:\n", + " # D3_output[dephy]=MIMICA_3D[mimica]\n", + " # D3_output[dephy].attrs['standard_name']= Output_3D[dephy]['std_name']\n", + " # D3_output[dephy].attrs['units']= Output_3D[dephy]['units'] \n", " \n", " \n", " # Changing time format\n", @@ -528,23 +1828,30 @@ "\n", "def convert_time_from_minutes_to_seconds_new(file, file_time_modified):\n", "\n", - " # Open dataset\n", - " ds = xr.open_dataset(file)\n", - " \n", - " # Force correct encoding\n", + " # Remove existing file if it exists\n", + " if os.path.exists(file_time_modified):\n", + " os.remove(file_time_modified)\n", + "\n", + " ds = xr.open_dataset(file) \n", + "\n", + " # Ensure all units attributes are strings to avoid xarray CF decoding errors later\n", + " for var in ds.variables:\n", + " if 'units' in ds[var].attrs and not isinstance(ds[var].attrs['units'], str):\n", + " ds[var].attrs['units'] = str(ds[var].attrs['units'])\n", + "\n", + " # Force correct time encoding in seconds\n", " ds.time.encoding[\"units\"] = \"seconds since 2020-03-12 22:00:00\"\n", - " ds.time.encoding[\"calendar\"] = \"proleptic_gregorian\" \n", - " \n", + " ds.time.encoding[\"calendar\"] = \"proleptic_gregorian\"\n", "\n", " # Save modified dataset\n", " ds.to_netcdf(file_time_modified)\n", "\n", - " return ds \n", - "\n" + " return ds \n" ] }, { "cell_type": "markdown", + "id": "f9efee43", "metadata": {}, "source": [ "# Simulation with ice part 1: FixN" @@ -552,7 +1859,8 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, + "id": "4b681498", "metadata": {}, "outputs": [], "source": [ @@ -564,650 +1872,235 @@ "COMBLE_FixN_256_TS= xr.open_dataset(native_outputs_path+'COMBLE_FixN_256x256/OUTPUT/T_S.nc')" ] }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "metadata": {} - }, - "outputs": [], - "source": [ - "Stat_output_FixN_256=create_stat_output(COMBLE_FixN_256_prof,COMBLE_FixN_256_prof_cl,COMBLE_FixN_256_surf,\n", - " COMBLE_FixN_256_TS,'MIMICA_Lx25_dx100_FixN_alt',True)" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "metadata": {} - }, - "outputs": [], - "source": [ - "OUTPUT_2D_FixN_256=create_2D_output(COMBLE_FixN_256_surf,'MIMICA_Lx25_dx100_FixN_2D_alt',True)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "metadata": {} - }, - "outputs": [], - "source": [ - "OUTPUT_3D_FixN_256=create_3D_output(COMBLE_FixN_256_3D,'MIMICA_Lx25_dx100_FixN_3D_alt',True)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create netcdf files for FixN" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "metadata": {} - }, - "outputs": [], - "source": [ - "Stat_output_FixN_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN'+'.nc',mode='w',engine=\"netcdf4\")" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "OUTPUT_2D_FixN_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_2D'+'.nc',mode='w',engine=\"netcdf4\")" - ] - }, { "cell_type": "code", "execution_count": 11, + "id": "8ad7c8ce", "metadata": {}, "outputs": [], "source": [ - "OUTPUT_3D_FixN_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_3D'+'.nc',mode='w',engine=\"netcdf4\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Simulation without ice part 1 : FixN noice" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "COMBLE_FixN_noice_256_prof= xr.open_dataset(native_outputs_path+'COMBLE_FixN_noice_256x256/OUTPUT/profiles_tot.nc')\n", - "COMBLE_FixN_noice_256_prof_cl=xr.open_dataset(native_outputs_path+'COMBLE_FixN_noice_256x256/OUTPUT/profiles_cl.nc')\n", - "COMBLE_FixN_noice_256_surf= xr.open_dataset(native_outputs_path+'COMBLE_FixN_noice_256x256/OUTPUT/slice_surf.nc')\n", - "COMBLE_FixN_noice_256_3D= xr.open_dataset(native_outputs_path+'COMBLE_FixN_noice_256x256/OUTPUT/COMBLE_MPI.nc')\n", - "COMBLE_FixN_noice_256_TS= xr.open_dataset(native_outputs_path+'COMBLE_FixN_noice_256x256/OUTPUT/T_S.nc')" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "Stat_output_FixN_noice_256=create_stat_output(COMBLE_FixN_noice_256_prof,COMBLE_FixN_noice_256_prof_cl,COMBLE_FixN_noice_256_surf,\n", - " COMBLE_FixN_noice_256_TS,'MIMICA_Lx25_dx100_FixN_noice',False)" + "Stat_output_FixN_256=create_stat_output(COMBLE_FixN_256_prof,COMBLE_FixN_256_prof_cl,COMBLE_FixN_256_surf,\n", + " COMBLE_FixN_256_TS,'MIMICA_Lx25_dx100_FixN',True)" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 12, + "id": "6e585f0a", "metadata": {}, "outputs": [], "source": [ - "OUTPUT_2D_FixN_noice_256=create_2D_output(COMBLE_FixN_noice_256_surf,'MIMICA_Lx25_dx100_FixN_noice_2D',False)" + "OUTPUT_2D_FixN_256=create_2D_output(COMBLE_FixN_256_surf,'MIMICA_Lx25_dx100_FixN_2D',True)" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, + "id": "04639028", "metadata": {}, "outputs": [], "source": [ - "OUTPUT_3D_FixN_noice_256=create_3D_output(COMBLE_FixN_noice_256_3D,'MIMICA_Lx25_dx100_FixN_noice_3D',False)" + "#OUTPUT_3D_FixN_256=create_3D_output(COMBLE_FixN_256_3D,'MIMICA_Lx25_dx100_FixN_3D_alt',True)" ] }, { "cell_type": "markdown", + "id": "02e25109", "metadata": {}, "source": [ - "### Create netcdf files for FixN noice" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [], - "source": [ - "Stat_output_FixN_noice_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_noice'+'.nc',mode='w',engine=\"netcdf4\")" + "### Create netcdf files for FixN" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 13, + "id": "ba6866e3", "metadata": {}, "outputs": [], "source": [ - "OUTPUT_2D_FixN_noice_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_noice_2D'+'.nc',mode='w',engine=\"netcdf4\")" + "Stat_output_FixN_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN'+'.nc',mode='w',engine=\"netcdf4\")" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 14, + "id": "06687f6c", "metadata": {}, "outputs": [], "source": [ - "OUTPUT_3D_FixN_noice_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_noice_3D'+'.nc',mode='w',engine=\"netcdf4\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Taking the last time step of the 3D outputs for the first iteration:" + "OUTPUT_2D_FixN_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_2D'+'.nc',mode='w',engine=\"netcdf4\")" ] }, { "cell_type": "code", "execution_count": null, + "id": "15d74538", "metadata": {}, "outputs": [], "source": [ - "OUTPUT_3D_FixN_256.isel(time=20).to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_3D_at_18UTC'+'.nc',mode='w',engine=\"netcdf4\")" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [], - "source": [ - "OUTPUT_3D_FixN_noice_256.isel(time=20).to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_noice_3D_at_18UTC'+'.nc',mode='w',engine=\"netcdf4\")" + "#OUTPUT_3D_FixN_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_3D'+'.nc',mode='w',engine=\"netcdf4\")" ] }, { "cell_type": "markdown", + "id": "56f256fa", "metadata": {}, "source": [ - "## Converting the time from minutes to seconds" + "## Converting time from minutes to seconds" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, + "id": "7e2f08b1", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Converting time in file MIMICA_Lx25_dx100_FixN_noice.nc saving in /proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/MIMICA_Lx25_dx100_FixN_noice.nc\n", - "Converting time in file MIMICA_Lx25_dx100_FixN_noice_2D.nc saving in /proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/MIMICA_Lx25_dx100_FixN_noice_2D.nc\n", - "Converting time in file MIMICA_Lx25_dx100_FixN_noice_3D.nc saving in /proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/MIMICA_Lx25_dx100_FixN_noice_3D.nc\n" + "Converting time in file MIMICA_Lx25_dx100_FixN.nc saving in /proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/MIMICA_Lx25_dx100_FixN.nc\n", + "Converting time in file MIMICA_Lx25_dx100_FixN_2D.nc saving in /proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/MIMICA_Lx25_dx100_FixN_2D.nc\n" ] } ], "source": [ "#Doing this only because Tim Juliano could not read properly the netcdf files after the conversion\n", - "file_names=[ 'MIMICA_Lx25_dx100_FixN.nc','MIMICA_Lx25_dx100_FixN_2D.nc', 'MIMICA_Lx25_dx100_FixN_3D.nc', \n", - " 'MIMICA_Lx25_dx100_FixN_noice.nc','MIMICA_Lx25_dx100_FixN_noice_2D.nc', 'MIMICA_Lx25_dx100_FixN_noice_3D.nc' ]\n", + "file_names=[ 'MIMICA_Lx25_dx100_FixN.nc','MIMICA_Lx25_dx100_FixN_2D.nc']#, 'MIMICA_Lx25_dx100_FixN_3D.nc', \n", "\n", "for ii_file in file_names:\n", " print(\"Converting time in file \",ii_file, \"saving in\",converted_outputs_path_time_mod+ii_file)\n", - " convert_time_from_minutes_to_seconds_new(converted_outputs_path+ii_file,converted_outputs_path_time_mod+ii_file) \n" + " convert_time_from_minutes_to_seconds_new(converted_outputs_path+ii_file,converted_outputs_path_time_mod+ii_file) " ] }, { "cell_type": "markdown", + "id": "aae0fa27", "metadata": {}, "source": [ - "# Part 2" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#COMBLE_Part2_Prog_Na_prof=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNa_new/OUTPUT/profiles_tot.nc')\n", - "#COMBLE_Part2_Prog_Na_prof_cl=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNa_new/OUTPUT/profiles_cl.nc')\n", - "#COMBLE_Part2_Prog_Na_surf=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNa_new/OUTPUT/slice_surf.nc')\n", - "#COMBLE_Part2_Prog_Na_3D=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNa_new/OUTPUT/COMBLE_MPI.nc')\n", - "#COMBLE_Part2_Prog_Na_TS=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNa_new/OUTPUT/T_S.nc')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#Stat_output_COMBLE_Part2_Prog_Na=create_stat_output(COMBLE_Part2_Prog_Na_prof,COMBLE_Part2_Prog_Na_prof_cl,COMBLE_Part2_Prog_Na_surf,\n", - "# COMBLE_Part2_Prog_Na_TS,'MIMICA_Lx25_dx100_Prog_Na_alt',True)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#OUTPUT_2D_COMBLE_Part2_Prog_Na=create_2D_output(COMBLE_Part2_Prog_Na_surf,'MIMICA_Lx25_dx100_Prog_Na_2D_alt',True)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#OUTPUT_3D_COMBLE_Part2_Prog_Na=create_3D_output(COMBLE_Part2_Prog_Na_3D,'MIMICA_Lx25_dx100_Prog_Na_3D_alt',True)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#COMBLE_Part2_Prog_NaNi_prof=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNaNi/OUTPUT/profiles_tot.nc')\n", - "#COMBLE_Part2_Prog_NaNi_prof_cl=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNaNi/OUTPUT/profiles_cl.nc')\n", - "#COMBLE_Part2_Prog_NaNi_surf=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNaNi/OUTPUT/slice_surf.nc')\n", - "#COMBLE_Part2_Prog_NaNi_3D=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNaNi/OUTPUT/COMBLE_MPI.nc')\n", - "#COMBLE_Part2_Prog_NaNi_TS=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNaNi/OUTPUT/T_S.nc')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#Stat_output_COMBLE_Part2_Prog_NaNi=create_stat_output(COMBLE_Part2_Prog_NaNi_prof,COMBLE_Part2_Prog_NaNi_prof_cl,COMBLE_Part2_Prog_NaNi_surf,\n", - "# COMBLE_Part2_Prog_NaNi_TS,'MIMICA_Lx25_dx100_Prog_NaNi_alt',True)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#OUTPUT_2D_COMBLE_Part2_Prog_NaNi=create_2D_output(COMBLE_Part2_Prog_NaNi_surf,'MIMICA_Lx25_dx100_Prog_NaNi_2D_alt',True)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#OUTPUT_3D_COMBLE_Part2_Prog_NaNi=create_3D_output(COMBLE_Part2_Prog_NaNi_3D,'MIMICA_Lx25_dx100_Prog_NaNi_3D_alt',True)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#COMBLE_Part2_Prog_Na_noice_prof=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNa_noice/OUTPUT/profiles_tot.nc')\n", - "#COMBLE_Part2_Prog_Na_noice_prof_cl=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNa_noice/OUTPUT/profiles_cl.nc')\n", - "#COMBLE_Part2_Prog_Na_noice_surf=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNa_noice/OUTPUT/slice_surf.nc')\n", - "#COMBLE_Part2_Prog_Na_noice_3D=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNa_noice/OUTPUT/COMBLE_MPI.nc')\n", - "#COMBLE_Part2_Prog_Na_noice_TS=xr.open_dataset(COMBLE_part2+'COMBLE_Part2_ProgNa_noice/OUTPUT/T_S.nc')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#Stat_output_COMBLE_Part2_Prog_Na_noice=create_stat_output(COMBLE_Part2_Prog_Na_noice_prof,COMBLE_Part2_Prog_Na_noice_prof_cl,COMBLE_Part2_Prog_Na_noice_surf,\n", - "# COMBLE_Part2_Prog_Na_noice_TS,'MIMICA_Lx25_dx100_Prog_Na_noice',False)" + "# Simulation without ice part 1" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, + "id": "1c223a8d", "metadata": {}, "outputs": [], "source": [ - "#OUTPUT_2D_COMBLE_Part2_Prog_Na_noice=create_2D_output(COMBLE_Part2_Prog_Na_noice_surf,'MIMICA_Lx25_dx100_Prog_Na_noice_2D',False)" + "#Reading MIMICA native outputs\n", + "COMBLE_FixN_noice_256_prof= xr.open_dataset(native_outputs_path+'COMBLE_FixN_noice_256x256/OUTPUT/profiles_tot.nc')\n", + "COMBLE_FixN_noice_256_prof_cl=xr.open_dataset(native_outputs_path+'COMBLE_FixN_noice_256x256/OUTPUT/profiles_cl.nc')\n", + "COMBLE_FixN_noice_256_surf= xr.open_dataset(native_outputs_path+'COMBLE_FixN_noice_256x256/OUTPUT/slice_surf.nc')\n", + "COMBLE_FixN_noice_256_3D= xr.open_dataset(native_outputs_path+'COMBLE_FixN_noice_256x256/OUTPUT/COMBLE_MPI.nc')\n", + "COMBLE_FixN_noice_256_TS= xr.open_dataset(native_outputs_path+'COMBLE_FixN_noice_256x256/OUTPUT/T_S.nc')" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, + "id": "1d9ba58d", "metadata": {}, "outputs": [], "source": [ - "#OUTPUT_3D_COMBLE_Part2_Prog_Na_noice=create_3D_output(COMBLE_Part2_Prog_Na_noice_3D,'MIMICA_Lx25_dx100_Prog_Na_noice_3D',False)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Create netcdf files" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Prog_Na" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The file /proj/mimica-chalmers-comble/users/x_abaro/COMBLE/Simulations_Folder_COMBLE/MIMICA_Lx25_dx100_Prog_Na_alt.nc has been deleted.\n" - ] - } - ], - "source": [ - "#file_path = simulation_path+'MIMICA_Lx25_dx100_Prog_Na_alt'+'.nc'\n", - "#\n", - "#if os.path.exists(file_path):\n", - "# os.remove(file_path)\n", - "# print(f\"The file {file_path} has been deleted.\")\n", - "#\n", - "#Stat_output_COMBLE_Part2_Prog_Na.to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_Na_alt'+'.nc',mode='w',engine=\"netcdf4\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The file /proj/mimica-chalmers-comble/users/x_abaro/COMBLE/Simulations_Folder_COMBLE/MIMICA_Lx25_dx100_Prog_Na_2D_alt.nc has been deleted.\n" - ] - } - ], - "source": [ - "#file_path = simulation_path+'MIMICA_Lx25_dx100_Prog_Na_2D_alt'+'.nc'\n", - "#\n", - "#if os.path.exists(file_path):\n", - "# os.remove(file_path)\n", - "# print(f\"The file {file_path} has been deleted.\")\n", - "#\n", - "#OUTPUT_2D_COMBLE_Part2_Prog_Na.to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_Na_2D_alt'+'.nc',mode='w',engine=\"netcdf4\")" + "Stat_output_FixN_noice_256=create_stat_output(COMBLE_FixN_noice_256_prof,COMBLE_FixN_noice_256_prof_cl,COMBLE_FixN_noice_256_surf,\n", + " COMBLE_FixN_noice_256_TS,'MIMICA_Lx25_dx100_FixN_noice',False)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, + "id": "6dc0480d", "metadata": {}, "outputs": [], "source": [ - "#file_path = simulation_path+'MIMICA_Lx25_dx100_Prog_Na_3D_alt'+'.nc'\n", - "#\n", - "#if os.path.exists(file_path):\n", - "# os.remove(file_path)\n", - "# print(f\"The file {file_path} has been deleted.\")\n", - "#\n", - "#OUTPUT_3D_COMBLE_Part2_Prog_Na.to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_Na_3D_alt'+'.nc',mode='w',engine=\"netcdf4\")" + "OUTPUT_2D_FixN_noice_256=create_2D_output(COMBLE_FixN_noice_256_surf,'MIMICA_Lx25_dx100_FixN_noice_2D',False)" ] }, { "cell_type": "code", "execution_count": null, + "id": "43c46e90", "metadata": {}, "outputs": [], "source": [ - "#OUTPUT_3D_COMBLE_Part2_Prog_Na.isel(time=20).to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_Na_3D_alt_at_18UTC'+'.nc',mode='w',engine=\"netcdf4\")" + "#OUTPUT_3D_FixN_noice_256=create_3D_output(COMBLE_FixN_noice_256_3D,'MIMICA_Lx25_dx100_FixN_noice_3D',False)" ] }, { "cell_type": "markdown", + "id": "b29b5a29", "metadata": {}, "source": [ - "### Prog_NaNi" + "# Create Netcdf files for FixN noice" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, + "id": "9c86e6ce", "metadata": {}, "outputs": [], "source": [ - "#file_path = simulation_path+'MIMICA_Lx25_dx100_Prog_NaNi_alt'+'.nc'\n", - "#\n", - "#if os.path.exists(file_path):\n", - "# os.remove(file_path)\n", - "# print(f\"The file {file_path} has been deleted.\")\n", - "#\n", - "#Stat_output_COMBLE_Part2_Prog_NaNi.to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_NaNi_alt'+'.nc',mode='w',engine=\"netcdf4\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#file_path = simulation_path+'MIMICA_Lx25_dx100_Prog_NaNi_2D_alt'+'.nc'\n", - "#\n", - "#if os.path.exists(file_path):\n", - "# os.remove(file_path)\n", - "# print(f\"The file {file_path} has been deleted.\")\n", - "#\n", - "#OUTPUT_2D_COMBLE_Part2_Prog_NaNi.to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_NaNi_2D_alt'+'.nc',mode='w',engine=\"netcdf4\")" + "Stat_output_FixN_noice_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_noice'+'.nc',mode='w',engine=\"netcdf4\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, + "id": "2139d86d", "metadata": {}, "outputs": [], "source": [ - "#file_path = simulation_path+'MIMICA_Lx25_dx100_Prog_NaNi_3D_alt'+'.nc'\n", - "#\n", - "#if os.path.exists(file_path):\n", - "# os.remove(file_path)\n", - "# print(f\"The file {file_path} has been deleted.\")\n", - "#\n", - "#OUTPUT_3D_COMBLE_Part2_Prog_NaNi.to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_NaNi_3D_alt'+'.nc',mode='w',engine=\"netcdf4\")" + "OUTPUT_2D_FixN_noice_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_noice_2D'+'.nc',mode='w',engine=\"netcdf4\")" ] }, { "cell_type": "code", "execution_count": null, + "id": "72dc3205", "metadata": {}, "outputs": [], "source": [ - "#OUTPUT_3D_COMBLE_Part2_Prog_NaNi.isel(time=20).to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_NaNi_3D_alt_at_18UTC'+'.nc',mode='w',engine=\"netcdf4\")" + "#OUTPUT_3D_FixN_noice_256.to_netcdf(path=converted_outputs_path+'MIMICA_Lx25_dx100_FixN_noice_3D'+'.nc',mode='w',engine=\"netcdf4\")" ] }, { "cell_type": "markdown", + "id": "2c700573", "metadata": {}, "source": [ - "### Prog_Na_noice" + "# Converting time from minutes to seconds" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#file_path = simulation_path+'MIMICA_Lx25_dx100_Prog_Na_noice'+'.nc'\n", - "#\n", - "#if os.path.exists(file_path):\n", - "# os.remove(file_path)\n", - "# print(f\"The file {file_path} has been deleted.\")\n", - "#\n", - "#Stat_output_COMBLE_Part2_Prog_Na_noice.to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_Na_noice'+'.nc',mode='w',engine=\"netcdf4\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#file_path = simulation_path+'MIMICA_Lx25_dx100_Prog_Na_noice_2D'+'.nc'\n", - "#\n", - "#if os.path.exists(file_path):\n", - "# os.remove(file_path)\n", - "# print(f\"The file {file_path} has been deleted.\")\n", - "#\n", - "#OUTPUT_2D_COMBLE_Part2_Prog_Na_noice.to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_Na_noice_2D'+'.nc',mode='w',engine=\"netcdf4\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#file_path = simulation_path+'MIMICA_Lx25_dx100_Prog_Na_noice_3D'+'.nc'\n", - "#\n", - "#if os.path.exists(file_path):\n", - "# os.remove(file_path)\n", - "# print(f\"The file {file_path} has been deleted.\")\n", - "#\n", - "#OUTPUT_3D_COMBLE_Part2_Prog_Na_noice.to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_Na_noice_3D'+'.nc',mode='w',engine=\"netcdf4\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#OUTPUT_3D_COMBLE_Part2_Prog_Na_noice.isel(time=20).to_netcdf(path=simulation_path+'MIMICA_Lx25_dx100_Prog_Na_noice_3D_at_18UTC'+'.nc',mode='w',engine=\"netcdf4\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def convert_time_from_minutes_to_seconds(file,file_time_modified):\n", - " # Open dataset\n", - " ds = xr.open_dataset(file) # Replace with actual file\n", - "\n", - " # Check if 'units' attribute exists\n", - " if 'units' in ds['time'].attrs:\n", - " # Extract the reference time from the attribute\n", - " import re\n", - " match = re.search(r\"since\\s(.+)\", ds['time'].attrs['units'])\n", - " if match:\n", - " reference_time_str = match.group(1)\n", - " reference_time = np.datetime64(reference_time_str)\n", - " else:\n", - " raise ValueError(\"Could not extract reference time from units attribute.\")\n", - " else:\n", - " # If units attribute is missing, define a reference time manually\n", - " print(\"Warning: No 'units' attribute found. Setting reference time manually.\")\n", - " reference_time = ds['time'].values[0] # Use the first time entry as reference\n", - " reference_time_str = str(reference_time) # Convert to string\n", - "\n", - " # Ensure time is in datetime64 format\n", - " ds['time'] = reference_time + (ds['time'] - reference_time) * 60 # Convert from minutes to seconds\n", - "\n", - " # Update metadata to reflect seconds instead of minutes\n", - " ds['time'].attrs['units'] = f\"seconds since {reference_time_str}\"\n", - " \n", - " # Move 'units' from attributes to encoding\n", - " ds['time'].encoding['units'] = ds['time'].attrs.pop('units')\n", - "\n", - " # Save the updated dataset\n", - " ds.to_netcdf(file_time_modified)\n", - "\n", - " # Print the updated time values and attributes\n", - " #print(ds['time'].values) # Ensure values are still datetime64[ns]\n", - " #print(ds['time'].attrs) # Check that units now say \"seconds since ...\"\n", - " \n", - " #return ds\n", - "\n", - "\n", - "def convert_time_from_minutes_to_seconds_new(file, file_time_modified):\n", - "\n", - " # Open dataset\n", - " ds = xr.open_dataset(file)\n", - " \n", - " # Force correct encoding\n", - " ds.time.encoding[\"units\"] = \"seconds since 2020-03-12 22:00:00\"\n", - " ds.time.encoding[\"calendar\"] = \"proleptic_gregorian\" \n", - " \n", - "\n", - " # Save modified dataset\n", - " ds.to_netcdf(file_time_modified)\n", - "\n", - " return ds" - ] - }, - { - "cell_type": "code", - "execution_count": 9, + "execution_count": 21, + "id": "a3fc8ad5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Converting time in file MIMICA_Lx25_dx100_FixN.nc saving in /proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/MIMICA_Lx25_dx100_FixN.nc\n", - "Converting time in file MIMICA_Lx25_dx100_FixN_2D.nc saving in /proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/MIMICA_Lx25_dx100_FixN_2D.nc\n", - "Converting time in file MIMICA_Lx25_dx100_FixN_3D.nc saving in /proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/MIMICA_Lx25_dx100_FixN_3D.nc\n" + "Converting time in file MIMICA_Lx25_dx100_FixN_noice.nc saving in /proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/MIMICA_Lx25_dx100_FixN_noice.nc\n", + "Converting time in file MIMICA_Lx25_dx100_FixN_noice_2D.nc saving in /proj/bolinc/users/x_abaro/MIMICA_radiation/COMBLE_CONVERTED_time_mod/MIMICA_Lx25_dx100_FixN_noice_2D.nc\n" ] } ], "source": [ - "#file_names=['MIMICA_Lx25_dx100_FixN_alt.nc','MIMICA_Lx25_dx100_FixN_noice.nc','MIMICA_Lx25_dx100_Prog_Na_alt.nc','MIMICA_Lx25_dx100_Prog_NaNi_alt.nc',\n", - "# 'MIMICA_Lx25_dx100_Prog_Na_noice.nc']\n", - "\n", - "file_names=[ 'MIMICA_Lx25_dx100_FixN.nc','MIMICA_Lx25_dx100_FixN_2D.nc', 'MIMICA_Lx25_dx100_FixN_3D.nc' ]\n", + "#Doing this only because Tim Juliano could not read properly the netcdf files after the conversion\n", + "file_names= ['MIMICA_Lx25_dx100_FixN_noice.nc','MIMICA_Lx25_dx100_FixN_noice_2D.nc'] # 'MIMICA_Lx25_dx100_FixN_noice_3D.nc' ]\n", "\n", "for ii_file in file_names:\n", " print(\"Converting time in file \",ii_file, \"saving in\",converted_outputs_path_time_mod+ii_file)\n", - " convert_time_from_minutes_to_seconds_new(converted_outputs_path+ii_file,converted_outputs_path_time_mod+ii_file) \n", - "# print(\" \")" + " convert_time_from_minutes_to_seconds_new(converted_outputs_path+ii_file,converted_outputs_path_time_mod+ii_file) " ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, + "id": "a5e8bea5", "metadata": {}, "outputs": [], "source": [] @@ -1215,7 +2108,7 @@ ], "metadata": { "kernelspec": { - "display_name": "myenv", + "display_name": "research", "language": "python", "name": "python3" }, @@ -1229,10 +2122,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.11.5" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } - diff --git a/output_les/mimica/sandbox/MIMICA_Lx25_dx100_FixN.nc b/output_les/mimica/sandbox/MIMICA_Lx25_dx100_FixN.nc index 59f5db9f..32b63149 100644 Binary files a/output_les/mimica/sandbox/MIMICA_Lx25_dx100_FixN.nc and b/output_les/mimica/sandbox/MIMICA_Lx25_dx100_FixN.nc differ diff --git a/output_les/mimica/sandbox/MIMICA_Lx25_dx100_FixN_noice.nc b/output_les/mimica/sandbox/MIMICA_Lx25_dx100_FixN_noice.nc index cf464350..6973eafe 100644 Binary files a/output_les/mimica/sandbox/MIMICA_Lx25_dx100_FixN_noice.nc and b/output_les/mimica/sandbox/MIMICA_Lx25_dx100_FixN_noice.nc differ