From 0d0bc7b0e9d752c98fe431ad1056a8edf3d86747 Mon Sep 17 00:00:00 2001 From: lkugler <lukas.kugler@gmail.com> Date: Tue, 23 May 2023 19:04:34 +0200 Subject: [PATCH] sphinx compatible config imports --- dartwrf/__init__.py | 1 + dartwrf/assim_synth_obs.py | 6 +- dartwrf/create_obs_upfront.py | 5 +- dartwrf/create_obsseq.py | 4 +- dartwrf/create_wbubble_wrfinput.py | 4 +- dartwrf/dart_nml.py | 4 +- dartwrf/evaluate_obs_space.py | 4 +- dartwrf/evaluate_posterior.py | 4 +- dartwrf/evaluate_prior.py | 4 +- dartwrf/exp_config.py | 6 +- dartwrf/obs/calculate_obs_locations.py | 4 +- dartwrf/obskind.py | 335 +++++++++++++++++++++++++ dartwrf/obsseq.py | 2 +- dartwrf/obsseq_2dim.py | 2 +- dartwrf/obsseq_to_netcdf.py | 4 +- dartwrf/prep_IC_prior.py | 4 +- dartwrf/prepare_namelist.py | 4 +- dartwrf/prepare_wrfrundir.py | 8 +- dartwrf/run_obs_diag.py | 4 +- dartwrf/server_config.py | 45 +--- dartwrf/update_IC.py | 4 +- dartwrf/utils.py | 1 - dartwrf/workflows.py | 94 +++---- dartwrf/wrfinput_add_geo.py | 4 +- dartwrf/wrfout_add_geo.py | 4 +- docs/source/conf.py | 3 +- docs/source/dartwrf.rst | 55 +++- tests/test_assim.py | 2 +- tests/test_dart-rttov.py | 1 - tests/test_obsseq.py | 2 +- 30 files changed, 466 insertions(+), 158 deletions(-) create mode 100644 dartwrf/obskind.py mode change 100644 => 100755 dartwrf/server_config.py diff --git a/dartwrf/__init__.py b/dartwrf/__init__.py index e69de29..b680692 100644 --- a/dartwrf/__init__.py +++ b/dartwrf/__init__.py @@ -0,0 +1 @@ +__all__ = [] \ No newline at end of file diff --git a/dartwrf/assim_synth_obs.py b/dartwrf/assim_synth_obs.py index 7cbdfe9..48b74ac 100755 --- a/dartwrf/assim_synth_obs.py +++ b/dartwrf/assim_synth_obs.py @@ -10,8 +10,10 @@ from dartwrf import wrfout_add_geo from dartwrf import obsseq from dartwrf import dart_nml -from exp_config import exp -from server_config import cluster +from dartwrf import exp_config +exp = exp_config.exp +from dartwrf import server_config +cluster = server_config.cluster wrfout_format = 'wrfout_d01_%Y-%m-%d_%H:%M:%S' diff --git a/dartwrf/create_obs_upfront.py b/dartwrf/create_obs_upfront.py index d89b910..4cf876b 100755 --- a/dartwrf/create_obs_upfront.py +++ b/dartwrf/create_obs_upfront.py @@ -4,12 +4,11 @@ import time as time_module import datetime as dt import numpy as np -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster from dartwrf.utils import copy, print import dartwrf.create_obsseq as osq from dartwrf import obsseq - from dartwrf import assim_synth_obs as aso tformat = '%Y-%m-%d_%H:%M' diff --git a/dartwrf/create_obsseq.py b/dartwrf/create_obsseq.py index bf3b049..b7792f1 100755 --- a/dartwrf/create_obsseq.py +++ b/dartwrf/create_obsseq.py @@ -7,10 +7,10 @@ import numpy as np import datetime as dt from pysolar.solar import get_altitude, get_azimuth -from server_config import cluster +from dartwrf.server_config import cluster from dartwrf.obs import calculate_obs_locations as col from dartwrf import utils -from obskind import obs_kind_nrs # dictionary string => DART internal indices +from dartwrf.obskind import obs_kind_nrs # dictionary string => DART internal indices # position on earth for RTTOV ray geometry lat0 = 45. diff --git a/dartwrf/create_wbubble_wrfinput.py b/dartwrf/create_wbubble_wrfinput.py index 5f354ad..bc79875 100644 --- a/dartwrf/create_wbubble_wrfinput.py +++ b/dartwrf/create_wbubble_wrfinput.py @@ -3,8 +3,8 @@ from re import U import datetime as dt import numpy as np -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster import netCDF4 as nc dx_km = 2 diff --git a/dartwrf/dart_nml.py b/dartwrf/dart_nml.py index 15113e4..0792353 100644 --- a/dartwrf/dart_nml.py +++ b/dartwrf/dart_nml.py @@ -1,7 +1,7 @@ from dartwrf.utils import append_file -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster earth_radius_km = 6370 diff --git a/dartwrf/evaluate_obs_space.py b/dartwrf/evaluate_obs_space.py index 5b113dd..0436d92 100755 --- a/dartwrf/evaluate_obs_space.py +++ b/dartwrf/evaluate_obs_space.py @@ -3,8 +3,8 @@ import time as time_module import datetime as dt import numpy as np -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster from dartwrf import assim_synth_obs as aso def get_previous_obsseq_file(time): diff --git a/dartwrf/evaluate_posterior.py b/dartwrf/evaluate_posterior.py index 6b3c9a6..bb8465b 100755 --- a/dartwrf/evaluate_posterior.py +++ b/dartwrf/evaluate_posterior.py @@ -3,8 +3,8 @@ import time as time_module import datetime as dt import numpy as np -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster from dartwrf import assim_synth_obs as aso diff --git a/dartwrf/evaluate_prior.py b/dartwrf/evaluate_prior.py index fec5f87..b13e48f 100755 --- a/dartwrf/evaluate_prior.py +++ b/dartwrf/evaluate_prior.py @@ -3,8 +3,8 @@ import time as time_module import datetime as dt import numpy as np -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster from dartwrf.utils import symlink, copy, sed_inplace, append_file, mkdir, try_remove, print, shell from dartwrf import assim_synth_obs as aso diff --git a/dartwrf/exp_config.py b/dartwrf/exp_config.py index c7fa14e..71650ab 100644 --- a/dartwrf/exp_config.py +++ b/dartwrf/exp_config.py @@ -1,16 +1,16 @@ from dartwrf import utils exp = utils.Experiment() -exp.expname = "exp_v1.22_P2_rr_VIS_obs20_loc10_oe3" +exp.expname = "template_experiment" exp.model_dx = 2000 exp.n_ens = 40 -exp.superob_km = False # False or int (spatial averaging of observations) +exp.superob_km = False # False or int (spatial averaging of observations, unit: km) exp.use_existing_obsseq = False # False or pathname (use precomputed obs_seq.out files) #exp.use_existing_obsseq = '/users/students/lehre/advDA_s2023/dartwrf_tutorial/very_cold_observation.out' # path to the nature run, where we take observations from -exp.nature_wrfout = '/jetfs/scratch/lkugler/data/sim_archive/exp_v1.18_P1_nature/2008-07-30_06:00/1/wrfout_d01_%Y-%m-%d_%H:%M:%S' +exp.nature_wrfout = '/mnt/jetfs/scratch/lkugler/data/sim_archive/exp_v1.18_P1_nature/2008-07-30_06:00/1/wrfout_d01_%Y-%m-%d_%H:%M:%S' exp.input_profile = '/mnt/jetfs/home/lkugler/data/initial_profiles/wrf/ens/2022-03-31/raso.fc.<iens>.wrfprof' diff --git a/dartwrf/obs/calculate_obs_locations.py b/dartwrf/obs/calculate_obs_locations.py index 422808f..59647b9 100755 --- a/dartwrf/obs/calculate_obs_locations.py +++ b/dartwrf/obs/calculate_obs_locations.py @@ -7,8 +7,8 @@ import numpy as np import datetime as dt import xarray as xr -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster ##################### # Global variables diff --git a/dartwrf/obskind.py b/dartwrf/obskind.py new file mode 100644 index 0000000..73e38d0 --- /dev/null +++ b/dartwrf/obskind.py @@ -0,0 +1,335 @@ +# this file is autogenerated +obs_kind_nrs = {"RADIOSONDE_U_WIND_COMPONENT": 1, +"RADIOSONDE_V_WIND_COMPONENT": 2, +"RADIOSONDE_GEOPOTENTIAL_HGT": 3, +"RADIOSONDE_SURFACE_PRESSURE": 4, +"RADIOSONDE_TEMPERATURE": 5, +"RADIOSONDE_SPECIFIC_HUMIDITY": 6, +"DROPSONDE_U_WIND_COMPONENT": 7, +"DROPSONDE_V_WIND_COMPONENT": 8, +"DROPSONDE_SURFACE_PRESSURE": 9, +"DROPSONDE_TEMPERATURE": 10, +"DROPSONDE_SPECIFIC_HUMIDITY": 11, +"AIRCRAFT_U_WIND_COMPONENT": 12, +"AIRCRAFT_V_WIND_COMPONENT": 13, +"AIRCRAFT_TEMPERATURE": 14, +"AIRCRAFT_SPECIFIC_HUMIDITY": 15, +"ACARS_U_WIND_COMPONENT": 16, +"ACARS_V_WIND_COMPONENT": 17, +"ACARS_TEMPERATURE": 18, +"ACARS_SPECIFIC_HUMIDITY": 19, +"MARINE_SFC_U_WIND_COMPONENT": 20, +"MARINE_SFC_V_WIND_COMPONENT": 21, +"MARINE_SFC_TEMPERATURE": 22, +"MARINE_SFC_SPECIFIC_HUMIDITY": 23, +"MARINE_SFC_PRESSURE": 24, +"LAND_SFC_U_WIND_COMPONENT": 25, +"LAND_SFC_V_WIND_COMPONENT": 26, +"LAND_SFC_TEMPERATURE": 27, +"LAND_SFC_SPECIFIC_HUMIDITY": 28, +"LAND_SFC_PRESSURE": 29, +"SAT_U_WIND_COMPONENT": 30, +"SAT_V_WIND_COMPONENT": 31, +"ATOV_TEMPERATURE": 32, +"AIRS_TEMPERATURE": 33, +"AIRS_SPECIFIC_HUMIDITY": 34, +"GPS_PRECIPITABLE_WATER": 35, +"VADWND_U_WIND_COMPONENT": 36, +"VADWND_V_WIND_COMPONENT": 37, +"CIMMS_AMV_U_WIND_COMPONENT": 38, +"CIMMS_AMV_V_WIND_COMPONENT": 39, +"DOPPLER_RADIAL_VELOCITY": 40, +"RADAR_REFLECTIVITY": 41, +"RADAR_CLEARAIR_REFLECTIVITY": 42, +"PRECIPITATION_FALL_SPEED": 43, +"METAR_U_10_METER_WIND": 44, +"METAR_V_10_METER_WIND": 45, +"METAR_TEMPERATURE_2_METER": 46, +"METAR_SPECIFIC_HUMIDITY_2_METER": 47, +"METAR_SURFACE_PRESSURE": 48, +"METAR_POT_TEMP_2_METER": 49, +"DEWPOINT": 50, +"DEWPOINT_2_METER": 51, +"BUOY_DEWPOINT": 52, +"SHIP_DEWPOINT": 53, +"SYNOP_DEWPOINT": 54, +"AIREP_DEWPOINT": 55, +"AMDAR_DEWPOINT": 56, +"PILOT_DEWPOINT": 57, +"BOGUS_DEWPOINT": 58, +"AIRS_DEWPOINT": 59, +"METAR_DEWPOINT_2_METER": 60, +"RADIOSONDE_DEWPOINT": 61, +"DROPSONDE_DEWPOINT": 62, +"AIRCRAFT_DEWPOINT": 63, +"ACARS_DEWPOINT": 64, +"MARINE_SFC_DEWPOINT": 65, +"LAND_SFC_DEWPOINT": 66, +"RADIOSONDE_RELATIVE_HUMIDITY": 67, +"DROPSONDE_RELATIVE_HUMIDITY": 68, +"AIRCRAFT_RELATIVE_HUMIDITY": 69, +"ACARS_RELATIVE_HUMIDITY": 70, +"MARINE_SFC_RELATIVE_HUMIDITY": 71, +"LAND_SFC_RELATIVE_HUMIDITY": 72, +"METAR_RELATIVE_HUMIDITY_2_METER": 73, +"AIRS_RELATIVE_HUMIDITY": 74, +"MESONET_RELATIVE_HUMIDITY": 75, +"RADIOSONDE_SURFACE_ALTIMETER": 76, +"DROPSONDE_SURFACE_ALTIMETER": 77, +"MARINE_SFC_ALTIMETER": 78, +"LAND_SFC_ALTIMETER": 79, +"METAR_ALTIMETER": 80, +"MESONET_SURFACE_ALTIMETER": 81, +"TEMPERATURE": 82, +"SPECIFIC_HUMIDITY": 83, +"PRESSURE": 84, +"GPSRO_REFRACTIVITY": 85, +"VORTEX_LAT": 86, +"VORTEX_LON": 87, +"VORTEX_PMIN": 88, +"VORTEX_WMAX": 89, +"BUOY_U_WIND_COMPONENT": 90, +"BUOY_V_WIND_COMPONENT": 91, +"BUOY_SURFACE_PRESSURE": 92, +"BUOY_TEMPERATURE": 93, +"SHIP_U_WIND_COMPONENT": 94, +"SHIP_V_WIND_COMPONENT": 95, +"SHIP_SURFACE_PRESSURE": 96, +"SHIP_TEMPERATURE": 97, +"SYNOP_U_WIND_COMPONENT": 98, +"SYNOP_V_WIND_COMPONENT": 99, +"SYNOP_SURFACE_PRESSURE": 100, +"SYNOP_SPECIFIC_HUMIDITY": 101, +"SYNOP_TEMPERATURE": 102, +"AIREP_U_WIND_COMPONENT": 103, +"AIREP_V_WIND_COMPONENT": 104, +"AIREP_PRESSURE": 105, +"AIREP_TEMPERATURE": 106, +"AMDAR_U_WIND_COMPONENT": 107, +"AMDAR_V_WIND_COMPONENT": 108, +"AMDAR_PRESSURE": 109, +"AMDAR_TEMPERATURE": 110, +"PILOT_U_WIND_COMPONENT": 111, +"PILOT_V_WIND_COMPONENT": 112, +"PILOT_PRESSURE": 113, +"PILOT_TEMPERATURE": 114, +"BOGUS_U_WIND_COMPONENT": 115, +"BOGUS_V_WIND_COMPONENT": 116, +"BOGUS_PRESSURE": 117, +"BOGUS_TEMPERATURE": 118, +"PROFILER_U_WIND_COMPONENT": 119, +"PROFILER_V_WIND_COMPONENT": 120, +"PROFILER_PRESSURE": 121, +"SATEM_THICKNESS": 122, +"NOAA_1_VTPR1_RADIANCE": 123, +"NOAA_2_VTPR1_RADIANCE": 124, +"NOAA_3_VTPR1_RADIANCE": 125, +"NOAA_4_VTPR1_RADIANCE": 126, +"NOAA_5_HIRS_RADIANCE": 127, +"NOAA_5_MSU_TB": 128, +"NOAA_5_AVHRR_RADIANCE": 129, +"NOAA_6_HIRS_RADIANCE": 130, +"NOAA_6_MSU_TB": 131, +"NOAA_6_AVHRR_RADIANCE": 132, +"NOAA_7_HIRS_RADIANCE": 133, +"NOAA_7_MSU_TB": 134, +"NOAA_7_AVHRR_RADIANCE": 135, +"NOAA_8_HIRS_RADIANCE": 136, +"NOAA_8_MSU_TB": 137, +"NOAA_8_AVHRR_RADIANCE": 138, +"NOAA_9_HIRS_RADIANCE": 139, +"NOAA_9_MSU_TB": 140, +"NOAA_9_AVHRR_RADIANCE": 141, +"NOAA_10_HIRS_RADIANCE": 142, +"NOAA_10_MSU_TB": 143, +"NOAA_10_AVHRR_RADIANCE": 144, +"NOAA_11_HIRS_RADIANCE": 145, +"NOAA_11_MSU_TB": 146, +"NOAA_11_AVHRR_RADIANCE": 147, +"NOAA_12_HIRS_RADIANCE": 148, +"NOAA_12_MSU_TB": 149, +"NOAA_12_AVHRR_RADIANCE": 150, +"NOAA_13_AVHRR_RADIANCE": 151, +"NOAA_14_HIRS_RADIANCE": 152, +"NOAA_14_MSU_TB": 153, +"NOAA_14_AVHRR_RADIANCE": 154, +"NOAA_15_HIRS_RADIANCE": 155, +"NOAA_15_AMSUA_TB": 156, +"NOAA_15_AMSUB_TB": 157, +"NOAA_15_AVHRR_RADIANCE": 158, +"NOAA_16_HIRS_RADIANCE": 159, +"NOAA_16_AMSUA_TB": 160, +"NOAA_16_AMSUB_TB": 161, +"NOAA_16_AVHRR_RADIANCE": 162, +"NOAA_17_HIRS_RADIANCE": 163, +"NOAA_17_AMSUA_TB": 164, +"NOAA_17_AMSUB_TB": 165, +"NOAA_17_AVHRR_RADIANCE": 166, +"NOAA_18_HIRS_RADIANCE": 167, +"NOAA_18_AMSUA_TB": 168, +"NOAA_18_AVHRR_RADIANCE": 169, +"NOAA_18_MHS_TB": 170, +"NOAA_19_HIRS_RADIANCE": 171, +"NOAA_19_AMSUA_TB": 172, +"NOAA_19_AVHRR_RADIANCE": 173, +"NOAA_19_MHS_TB": 174, +"NOAA_20_ATMS_TB": 175, +"NOAA_20_VIIRS_RADIANCE": 176, +"DMSP_8_SSMI_TB": 177, +"DMSP_9_SSMI_TB": 178, +"DMSP_10_SSMI_TB": 179, +"DMSP_11_SSMI_TB": 180, +"DMSP_11_SSMT2_TB": 181, +"DMSP_12_SSMI_TB": 182, +"DMSP_12_SSMT2_TB": 183, +"DMSP_13_SSMI_TB": 184, +"DMSP_14_SSMI_TB": 185, +"DMSP_14_SSMT2_TB": 186, +"DMSP_15_SSMI_TB": 187, +"DMSP_15_SSMT2_TB": 188, +"DMSP_16_SSMIS_TB": 189, +"DMSP_17_SSMIS_TB": 190, +"DMSP_18_SSMIS_TB": 191, +"DMSP_19_SSMIS_TB": 192, +"METEOSAT_1_MVIRI_RADIANCE": 193, +"METEOSAT_2_MVIRI_RADIANCE": 194, +"METEOSAT_3_MVIRI_RADIANCE": 195, +"METEOSAT_4_MVIRI_RADIANCE": 196, +"METEOSAT_5_MVIRI_RADIANCE": 197, +"METEOSAT_6_MVIRI_RADIANCE": 198, +"METEOSAT_7_MVIRI_RADIANCE": 199, +"GOES_4_SOUNDER_RADIANCE": 200, +"GOES_5_SOUNDER_RADIANCE": 201, +"GOES_6_SOUNDER_RADIANCE": 202, +"GOES_7_SOUNDER_RADIANCE": 203, +"GOES_8_IMAGER_RADIANCE": 204, +"GOES_8_SOUNDER_RADIANCE": 205, +"GOES_9_IMAGER_RADIANCE": 206, +"GOES_9_SOUNDER_RADIANCE": 207, +"GOES_10_IMAGER_RADIANCE": 208, +"GOES_10_SOUNDER_RADIANCE": 209, +"GOES_11_IMAGER_RADIANCE": 210, +"GOES_11_SOUNDER_RADIANCE": 211, +"GOES_12_IMAGER_RADIANCE": 212, +"GOES_12_SOUNDER_RADIANCE": 213, +"GOES_13_IMAGER_RADIANCE": 214, +"GOES_13_SOUNDER_RADIANCE": 215, +"GOES_14_IMAGER_RADIANCE": 216, +"GOES_14_SOUNDER_RADIANCE": 217, +"GOES_15_IMAGER_RADIANCE": 218, +"GOES_15_SOUNDER_RADIANCE": 219, +"GOES_16_ABI_RADIANCE": 220, +"GOES_17_ABI_RADIANCE": 221, +"GOES_18_ABI_RADIANCE": 222, +"GOES_19_ABI_RADIANCE": 223, +"GMS_1_IMAGER_RADIANCE": 224, +"GMS_2_IMAGER_RADIANCE": 225, +"GMS_3_IMAGER_RADIANCE": 226, +"GMS_4_IMAGER_RADIANCE": 227, +"GMS_5_IMAGER_RADIANCE": 228, +"FY2_2_VISSR_RADIANCE": 229, +"FY2_3_VISSR_RADIANCE": 230, +"FY2_4_VISSR_RADIANCE": 231, +"FY2_5_VISSR_RADIANCE": 232, +"FY2_7_VISSR_RADIANCE": 233, +"TRMM_1_TMI_TB": 234, +"ERS_1_ATSR_RADIANCE": 235, +"ERS_1_MWR_TB": 236, +"ERS_2_ATSR_RADIANCE": 237, +"ERS_2_MWR_TB": 238, +"EOS_1_MODIS_RADIANCE": 239, +"EOS_1_ASTER_RADIANCE": 240, +"EOS_2_AMSUA_TB": 241, +"EOS_2_AIRS_RADIANCE": 242, +"EOS_2_HSB_TB": 243, +"EOS_2_MODIS_RADIANCE": 244, +"EOS_2_AMSRE_TB": 245, +"METOP_1_HIRS_RADIANCE": 246, +"METOP_1_AMSUA_TB": 247, +"METOP_1_AVHRR_RADIANCE": 248, +"METOP_1_MHS_TB": 249, +"METOP_2_HIRS_RADIANCE": 250, +"METOP_2_AMSUA_TB": 251, +"METOP_2_AVHRR_RADIANCE": 252, +"METOP_2_MHS_TB": 253, +"METOP_3_AVHRR_RADIANCE": 254, +"ENVISAT_1_ATSR_RADIANCE": 255, +"ENVISAT_1_MWR_TB": 256, +"MSG_1_SEVIRI_RADIANCE": 257, +"MSG_2_SEVIRI_RADIANCE": 258, +"MSG_3_SEVIRI_RADIANCE": 259, +"MSG_4_SEVIRI_RADIANCE": 260, +"MSG_4_SEVIRI_TB": 261, +"MSG_4_SEVIRI_BDRF": 262, +"FY1_3_MVISR_RADIANCE": 263, +"FY1_4_MVISR_RADIANCE": 264, +"MTSAT_1_IMAGER_RADIANCE": 265, +"MTSAT_2_IMAGER_RADIANCE": 266, +"CORIOLIS_1_WINDSAT_TB": 267, +"JPSS_0_ATMS_TB": 268, +"JPSS_0_VIIRS_RADIANCE": 269, +"SENTINEL3_1_SLSTR_RADIANCE": 270, +"SENTINEL3_2_SLSTR_RADIANCE": 271, +"MEGHATR_1_SAPHIR_TB": 272, +"MEGHATR_1_MADRAS_TB": 273, +"FY3_1_MWTS_TB": 274, +"FY3_1_MWHS_TB": 275, +"FY3_1_IRAS_RADIANCE": 276, +"FY3_1_MWRI_TB": 277, +"FY3_2_MWTS_TB": 278, +"FY3_2_MWHS_TB": 279, +"FY3_2_MWRI_TB": 280, +"FY3_3_MWRI_TB": 281, +"FY3_3_MWTS2_TB": 282, +"FY3_3_MWHS2_TB": 283, +"FY3_3_MERSI1_RADIANCE": 284, +"FY3_4_MWRI_TB": 285, +"FY3_4_MWTS2_TB": 286, +"FY3_4_MWHS2_TB": 287, +"FY3_4_MERSI2_RADIANCE": 288, +"COMS_1_MI_RADIANCE": 289, +"METEOR_M_1_MSUMR_RADIANCE": 290, +"METEOR_M_2_MSUMR_RADIANCE": 291, +"METEOR_M_2_MTVZAGY_TB": 292, +"CALIPSO_1_IIR_RADIANCE": 293, +"GCOM_W_1_AMSR2_TB": 294, +"NIMBUS_3_MRIR_RADIANCE": 295, +"NIMBUS_4_THIR_RADIANCE": 296, +"NIMBUS_5_THIR_RADIANCE": 297, +"NIMBUS_6_HIRS_RADIANCE": 298, +"NIMBUS_6_SCAMS_TB": 299, +"NIMBUS_6_THIR_RADIANCE": 300, +"NIMBUS_7_SMMR_TB": 301, +"NIMBUS_7_THIR_RADIANCE": 302, +"HIMAWARI_8_AHI_RADIANCE": 303, +"HIMAWARI_9_AHI_RADIANCE": 304, +"MTG_1_FCI_RADIANCE": 305, +"SARAL_1_ALTIKA_TB": 306, +"METOPSG_1_ICI_TB": 307, +"METOPSG_1_METIMAGE_RADIANCE": 308, +"METOPSG_1_MWS_TB": 309, +"METOPSG_1_MWI_TB": 310, +"LANDSAT_4_TM_RADIANCE": 311, +"LANDSAT_5_TM_RADIANCE": 312, +"LANDSAT_7_TM_RADIANCE": 313, +"LANDSAT_8_TIRS_RADIANCE": 314, +"JASON_2_AMR_TB": 315, +"GPM_1_GMI_TB": 316, +"GPM_1_DPR_TB": 317, +"INSAT3_4_IMAGER_RADIANCE": 318, +"INSAT3_4_SOUNDER_RADIANCE": 319, +"INSAT3_5_IMAGER_RADIANCE": 320, +"INSAT3_5_SOUNDER_RADIANCE": 321, +"TICFIRE_1_MBFIRI_RADIANCE": 322, +"ISS_1_ECOSTRES_RADIANCE": 323, +"HJ1_2_IRMSS_RADIANCE": 324, +"GKOMPSAT2_1_AMI_RADIANCE": 325, +"GCOM_C_1_SGLI_RADIANCE": 326, +"SMOS_1_MIRAS_TB": 327, +"ORS_6_COWVR_TB": 328, +"FY4_1_AGRI_RADIANCE": 329, +"TROPICS_0_TROPICS_TB": 330, +"GF5_1_VIMS_RADIANCE": 331, +"HY2_1_MWRI_TB": 332, +"CLOUDSAT_1_CPR_TB": 333, +} \ No newline at end of file diff --git a/dartwrf/obsseq.py b/dartwrf/obsseq.py index 3508941..fc20e51 100755 --- a/dartwrf/obsseq.py +++ b/dartwrf/obsseq.py @@ -128,7 +128,7 @@ class ObsRecord(pd.DataFrame): def determine_nlayers(self): nlayers = 1 # first guess - from config.cfg import exp + from dartwrf.exp_config import exp if len(exp.observations) == 1: # obscfg = exp.observations[0] diff --git a/dartwrf/obsseq_2dim.py b/dartwrf/obsseq_2dim.py index ec08e03..c9a647c 100755 --- a/dartwrf/obsseq_2dim.py +++ b/dartwrf/obsseq_2dim.py @@ -19,7 +19,7 @@ import time as time_module import datetime as dt import numpy as np -from server_config import cluster +from dartwrf.server_config import cluster from dartwrf import utils from dartwrf import assim_synth_obs as aso from dartwrf import obsseq diff --git a/dartwrf/obsseq_to_netcdf.py b/dartwrf/obsseq_to_netcdf.py index 7bdc670..14b0447 100644 --- a/dartwrf/obsseq_to_netcdf.py +++ b/dartwrf/obsseq_to_netcdf.py @@ -1,7 +1,7 @@ import os, sys, glob, warnings -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster import dartwrf.run_obs_diag as rod def listdir_dirs(path): diff --git a/dartwrf/prep_IC_prior.py b/dartwrf/prep_IC_prior.py index 9b27d51..8ad84de 100755 --- a/dartwrf/prep_IC_prior.py +++ b/dartwrf/prep_IC_prior.py @@ -2,8 +2,8 @@ import os, sys, warnings, glob import datetime as dt import numpy as np -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster from dartwrf.utils import copy, clean_wrfdir, try_remove """ diff --git a/dartwrf/prepare_namelist.py b/dartwrf/prepare_namelist.py index 293fc23..c3e0e59 100755 --- a/dartwrf/prepare_namelist.py +++ b/dartwrf/prepare_namelist.py @@ -12,8 +12,8 @@ import os, sys, shutil, warnings import datetime as dt from docopt import docopt -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster from dartwrf.utils import sed_inplace, copy, symlink, mkdir def run(iens, begin, end, hist_interval=5, radt=5, archive=True, diff --git a/dartwrf/prepare_wrfrundir.py b/dartwrf/prepare_wrfrundir.py index 5fc2c5c..2d0b141 100755 --- a/dartwrf/prepare_wrfrundir.py +++ b/dartwrf/prepare_wrfrundir.py @@ -9,11 +9,11 @@ Returns: import os, sys, shutil import datetime as dt -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster -from utils import symlink, copy, link_contents -import prepare_namelist +from dartwrf.utils import symlink, copy, link_contents +from dartwrf import prepare_namelist if __name__ == '__main__': diff --git a/dartwrf/run_obs_diag.py b/dartwrf/run_obs_diag.py index 49132b0..fa1e78e 100644 --- a/dartwrf/run_obs_diag.py +++ b/dartwrf/run_obs_diag.py @@ -1,7 +1,7 @@ import os, sys, shutil, glob -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster from dartwrf.utils import symlink, copy, sed_inplace, append_file, shell rundir_program = '/home/fs71386/lkugler/data/run_DART/' diff --git a/dartwrf/server_config.py b/dartwrf/server_config.py old mode 100644 new mode 100755 index a978a51..bd9c6b1 --- a/dartwrf/server_config.py +++ b/dartwrf/server_config.py @@ -1,47 +1,6 @@ -import os, sys -import datetime as dt +"""Cluster configuration file, see docstring of ClusterConfig class in dartwrf/utils.py for details""" from dartwrf import utils -from cfg import exp - -"""Configuration name docs - -When coding, use attributes of a dictionary like this: -$ from cfg import exp, cluster -$ path = cluster.archivedir - - -attribute name | description ------------------------------------------------------- -name any string (currently unused) - -python path of python version to use -python_enstools path of python version to use for verification script (not provided) -ncks path to 'ncks' program; type 'which ncks' to find the path, - if it doesn't exist, try to load the module first ('module load nco') -ideal path to WRF's ideal.exe -wrfexe path to WRF's wrf.exe - -wrf_rundir_base path for temporary files for WRF -dart_rundir_base path for temporary files for DART -archive_base path for long-time output storage - -srcdir path to where WRF has been compiled, including the 'run' folder of WRF, e.g. /home/WRF-4.3/run -dart_srcdir path to DART compile directory, e.g. /home/DART-9.11.9/models/wrf/work -rttov_srcdir path to RTTOV compile directory, e.g. /home/RTTOV13/rtcoef_rttov13/ -scriptsdir path where DART-WRF scripts reside, e.g. /home/DART-WRF/scripts - -namelist path to a namelist template; strings like <hist_interval>, will be overwritten in scripts/prepare_namelist.py -run_WRF path to script which runs WRF on a node of the cluster -obs_impact_filename path to obs_impact_filename (see DART guide; module assim_tools_mod and program obs_impact_tool) -geo_em path to NetCDF file of WRF domain (see WRF guide) - -slurm_cfg python dictionary, containing options of SLURM - defined in SLURM docs (https://slurm.schedmd.com/sbatch.html) - this configuration can be overwritten later on, for example: - 'dict(cluster.slurm_cfg, **cfg_update)' where - 'cfg_update = {"nodes": "2"}' -""" - +from dartwrf.exp_config import exp cluster = utils.ClusterConfig(exp) cluster.name = 'jet' diff --git a/dartwrf/update_IC.py b/dartwrf/update_IC.py index 5e74b46..16d856a 100755 --- a/dartwrf/update_IC.py +++ b/dartwrf/update_IC.py @@ -2,8 +2,8 @@ import os, sys, warnings import datetime as dt import netCDF4 as nc -from exp_config import exp -from server_config import cluster +from dartwrf.exp_config import exp +from dartwrf.server_config import cluster def update_initials_in_WRF_rundir(time): """Updates wrfrst-files in `/run_WRF/` directory diff --git a/dartwrf/utils.py b/dartwrf/utils.py index fb9151d..9c36880 100755 --- a/dartwrf/utils.py +++ b/dartwrf/utils.py @@ -3,7 +3,6 @@ import builtins as __builtin__ import subprocess import datetime as dt import re, tempfile -import importlib class Experiment(object): """Collection of variables regarding the experiment configuration""" diff --git a/dartwrf/workflows.py b/dartwrf/workflows.py index 45cba00..bbc67b4 100644 --- a/dartwrf/workflows.py +++ b/dartwrf/workflows.py @@ -5,9 +5,8 @@ e.g. assimilate() calls dartwrf/assim_synth_obs.py through the shell. This would not be necessary, but some users might want to use queueing systems (e.g. SLURM) which must call scripts. """ -import os, sys, shutil, glob, warnings +import os, sys, shutil, warnings import datetime as dt -import importlib from dartwrf.utils import script_to_str @@ -31,7 +30,7 @@ class WorkFlows(object): exp (obj): experiment configuration as defined in exp_config file """ - def copy_dartwrf_to_archive(): + def _copy_dartwrf_to_archive(): # Copy scripts to self.cluster.archivedir folder try: shutil.copytree(self.cluster.dartwrf_dir, self.cluster.archivedir+'/DART-WRF/') @@ -45,52 +44,6 @@ class WorkFlows(object): except: raise - # def copy_config_to_archive(): - # os.makedirs(self.cluster.scripts_rundir+'/config/', exist_ok=True) - - # # later, we can load the exp cfg with `from config.cfg import exp` - # shutil.copyfile('config/'+exp_config, self.cluster.scripts_rundir+'/config/cfg.py') - - # # later, we can load the cluster cfg with `from config.cluster import cluster` - # shutil.copyfile('config/'+server_config, self.cluster.scripts_rundir+'/config/cluster.py') # whatever server, the config name is always the same! - - print('------ start exp from ', exp_config, ' and ', server_config, ' ------') - - # experiment starts, we dont know where the code shall run - # => read the configuration file - - # copy the config files to this folder - this_dir = '/'.join(__file__.split('/')[:-1]) - try: - shutil.copyfile('config/'+server_config, this_dir+'/server_config.py') - except shutil.SameFileError: - pass - try: - shutil.copyfile('config/'+exp_config, this_dir+'/exp_config.py') - except shutil.SameFileError: - pass - - sys.path.append(this_dir) - from server_config import cluster - self.cluster = cluster - from exp_config import exp - self.exp = exp - - copy_dartwrf_to_archive() # includes config files - - # we set the path from where python should import dartwrf modules - self.cluster.python = 'export PYTHONPATH='+self.cluster.scripts_rundir+'; '+self.cluster.python - - # Set paths and backup scripts - self.cluster.log_dir = self.cluster.archivedir+'/logs/' - print('logging to', self.cluster.log_dir) - - if self.cluster.use_slurm: - self.cluster.slurm_scripts_dir = self.cluster.archivedir+'/slurm-scripts/' - print('SLURM scripts will be in', self.cluster.slurm_scripts_dir) - - # copy obs kind def to config, we will read a table from there - # file needs to exist within package so sphinx can read it def _obskind_read(): """Read dictionary of observation types + ID numbers ("kind") from DART f90 script and return it as python dictionary @@ -135,10 +88,45 @@ class WorkFlows(object): txt += '}' f.write(txt) - _dict_to_py(_obskind_read(), self.cluster.scripts_rundir+'/obskind.py') - - # probably not needed - # shutil.copy('config/'+server_config, 'config/cluster.py') # whatever server, the config name is always the same! + print('------ start exp from ', exp_config, ' and ', server_config, ' ------') + + # experiment starts, we dont know where the code shall run + # => read the configuration file + + # copy the config files to this folder + this_dir = '/'.join(__file__.split('/')[:-1]) + try: + shutil.copyfile('config/'+server_config, this_dir+'/server_config.py') + except shutil.SameFileError: + pass + try: + shutil.copyfile('config/'+exp_config, this_dir+'/exp_config.py') + except shutil.SameFileError: + pass + + sys.path.append(this_dir) + from server_config import cluster + self.cluster = cluster + from exp_config import exp + self.exp = exp + + # copy obs kind def to config, we will read a table from there + # file needs to exist within package so sphinx can read it + _dict_to_py(_obskind_read(), this_dir+'/obskind.py') + + _copy_dartwrf_to_archive() # includes config files + + # we set the path from where python should import dartwrf modules + self.cluster.python = 'export PYTHONPATH='+self.cluster.scripts_rundir+'; '+self.cluster.python + + # Set paths and backup scripts + self.cluster.log_dir = self.cluster.archivedir+'/logs/' + print('logging to', self.cluster.log_dir) + + if self.cluster.use_slurm: + self.cluster.slurm_scripts_dir = self.cluster.archivedir+'/slurm-scripts/' + print('SLURM scripts will be in', self.cluster.slurm_scripts_dir) + print('------ dartwrf experiment initialized ------') print('--------------------------------------------') diff --git a/dartwrf/wrfinput_add_geo.py b/dartwrf/wrfinput_add_geo.py index c4317bf..aa1400c 100755 --- a/dartwrf/wrfinput_add_geo.py +++ b/dartwrf/wrfinput_add_geo.py @@ -10,9 +10,7 @@ example call: """ import os, sys import netCDF4 as nc - -from exp_config import exp -from server_config import cluster +from dartwrf.server_config import cluster def run(geo_data_file, wrfinput_file): geo_ds = nc.Dataset(geo_data_file, 'r') diff --git a/dartwrf/wrfout_add_geo.py b/dartwrf/wrfout_add_geo.py index 48a9b96..8be29aa 100755 --- a/dartwrf/wrfout_add_geo.py +++ b/dartwrf/wrfout_add_geo.py @@ -1,8 +1,6 @@ import os, sys import netCDF4 as nc - -from exp_config import exp -from server_config import cluster +from dartwrf.server_config import cluster fields_old = ["XLAT_M", "XLONG_M", "CLAT", "XLONG_U", "XLONG_V", "XLAT_U", "XLAT_V"] diff --git a/docs/source/conf.py b/docs/source/conf.py index cdc7c64..4a482c9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,8 +11,7 @@ author = 'Lukas Kugler' release = '2023.2.21' # -- General configuration -sys.path.insert(0, os.path.abspath('.')) -sys.path.insert(0, os.path.abspath('../')) +sys.path.insert(0, os.path.abspath('../../')) master_doc = 'index' diff --git a/docs/source/dartwrf.rst b/docs/source/dartwrf.rst index d358f32..d8bab9e 100644 --- a/docs/source/dartwrf.rst +++ b/docs/source/dartwrf.rst @@ -7,20 +7,11 @@ Subpackages .. toctree:: :maxdepth: 4 - dartwrf.config dartwrf.obs Submodules ---------- -dartwrf.workflows module ------------------------- - -.. automodule:: dartwrf.workflows - :members: - :undoc-members: - :show-inheritance: - dartwrf.assim\_synth\_obs module -------------------------------- @@ -53,6 +44,22 @@ dartwrf.create\_wbubble\_wrfinput module :undoc-members: :show-inheritance: +dartwrf.dart\_nml module +------------------------ + +.. automodule:: dartwrf.dart_nml + :members: + :undoc-members: + :show-inheritance: + +dartwrf.evaluate\_obs\_space module +----------------------------------- + +.. automodule:: dartwrf.evaluate_obs_space + :members: + :undoc-members: + :show-inheritance: + dartwrf.evaluate\_posterior module ---------------------------------- @@ -69,10 +76,18 @@ dartwrf.evaluate\_prior module :undoc-members: :show-inheritance: -dartwrf.link\_dart\_rttov module --------------------------------- +dartwrf.exp\_config module +-------------------------- + +.. automodule:: dartwrf.exp_config + :members: + :undoc-members: + :show-inheritance: -.. automodule:: dartwrf.link_dart_rttov +dartwrf.obskind module +---------------------- + +.. automodule:: dartwrf.obskind :members: :undoc-members: :show-inheritance: @@ -133,6 +148,14 @@ dartwrf.run\_obs\_diag module :undoc-members: :show-inheritance: +dartwrf.server\_config module +----------------------------- + +.. automodule:: dartwrf.server_config + :members: + :undoc-members: + :show-inheritance: + dartwrf.update\_IC module ------------------------- @@ -149,6 +172,14 @@ dartwrf.utils module :undoc-members: :show-inheritance: +dartwrf.workflows module +------------------------ + +.. automodule:: dartwrf.workflows + :members: + :undoc-members: + :show-inheritance: + dartwrf.wrfinput\_add\_geo module --------------------------------- diff --git a/tests/test_assim.py b/tests/test_assim.py index aecc515..d53b53b 100644 --- a/tests/test_assim.py +++ b/tests/test_assim.py @@ -2,7 +2,7 @@ import os, shutil import datetime as dt from dartwrf import obsseq, assim_synth_obs -from config.cfg import cluster +from dartwrf.server_config import cluster class ExperimentConfiguration(object): def __init__(self): diff --git a/tests/test_dart-rttov.py b/tests/test_dart-rttov.py index 4d502b3..ada56bf 100644 --- a/tests/test_dart-rttov.py +++ b/tests/test_dart-rttov.py @@ -3,7 +3,6 @@ import numpy as np import datetime as dt import pandas as pd -from config.cfg import exp, cluster from dartwrf import obsseq import dartwrf.create_obsseq as osq import dartwrf.assim_synth_obs as aso diff --git a/tests/test_obsseq.py b/tests/test_obsseq.py index 96d7dbe..215df54 100644 --- a/tests/test_obsseq.py +++ b/tests/test_obsseq.py @@ -1,7 +1,7 @@ import os, filecmp, shutil import numpy as np -from config.cfg import exp, cluster +from dartwrf.server_config import cluster from dartwrf import obsseq -- GitLab