├── .gitignore
├── LICENSE
├── README.md
├── UMLs
├── absolute2absolute_svglinkpath.m
├── absolute2fullfile_svglinkpath.m
├── absolute2relative_svglinkpath.m
├── create_all_uml.m
├── create_index.m
├── create_uml_forcing.m
├── create_uml_tier1.m
├── create_uml_tier23.m
├── index.html
├── localize_svgs.m
├── open_index.m
├── rdir.m
├── readme.md
├── relative2absolute_svglinkpath.m
└── relativize_svgs.m
├── doc
├── CryoGridLogo_git.png
├── CryoGridLogo_git.svg
└── VEGETATION_CLM5_SEB.doc
├── notes_cryogrid_changes.pdf
└── source
├── +yaml
├── DateTime.m
├── MIT-license.txt
├── README.md
├── ReadYaml.m
├── ReadYamlRaw.m
├── Tests
│ ├── Data
│ │ ├── test_import
│ │ │ ├── file1.yaml
│ │ │ ├── file2.yaml
│ │ │ ├── file3.yaml
│ │ │ ├── file4.yaml
│ │ │ ├── import.mat
│ │ │ ├── import.yaml
│ │ │ ├── import_def.mat
│ │ │ ├── import_def.yaml
│ │ │ └── import_nonex.yaml
│ │ ├── test_inheritance
│ │ │ ├── inheritance.mat
│ │ │ ├── inheritance.yaml
│ │ │ ├── inheritance_loop.yaml
│ │ │ ├── inheritance_multiple.mat
│ │ │ └── inheritance_multiple.yaml
│ │ ├── test_misc
│ │ │ ├── bug6.yaml
│ │ │ ├── dos_CRLF.yaml
│ │ │ ├── miscellaneous.yaml
│ │ │ ├── spec_chars_utf8.yaml
│ │ │ └── unix_LF.yaml
│ │ └── test_primitives
│ │ │ ├── floating_points.mat
│ │ │ ├── floating_points.yaml
│ │ │ ├── indentation.mat
│ │ │ ├── indentation.yaml
│ │ │ ├── matrices.mat
│ │ │ ├── matrices.yaml
│ │ │ ├── sequence_mapping.mat
│ │ │ ├── sequence_mapping.yaml
│ │ │ ├── simple.mat
│ │ │ ├── simple.yaml
│ │ │ ├── time.mat
│ │ │ ├── time.yaml
│ │ │ ├── time_variants.mat
│ │ │ ├── time_variants.yaml
│ │ │ ├── usecase_struct_01.mat
│ │ │ ├── usecase_struct_01.yaml
│ │ │ └── whitespaces.yaml
│ ├── selftest_report.html
│ ├── selftest_yamlmatlab.m
│ ├── test_ReadYaml.m
│ └── test_WriteYaml.m
├── WriteYaml.m
├── datadump.m
├── deflateimports.m
├── doinheritance.m
├── dosubstitution.m
├── external
│ ├── LICENSE-2.0.txt
│ └── snakeyaml-1.9.jar
├── extras
│ ├── GetYamlVals.m
│ └── TimeVals2Cell.m
├── iscolumnvector.m
├── ismymatrix.m
├── isord.m
├── isrowvector.m
├── issingle.m
├── kwd_parent.m
├── makematrices.m
├── merge_struct.m
└── mergeimports.m
├── ESA_CCI
├── DATA
│ ├── DEM_gmted.m
│ ├── DEM_gmted_sequential.m
│ ├── ERA5_PREPROCESS_CCI.m
│ ├── GEOTHERMAL_Davies2013.m
│ ├── LANDCOVER.m
│ ├── LANDCOVER_CCI.m
│ ├── LANDCOVER_CCI_sequential.m
│ └── assign_range.m
├── DATA_ASSIMILATION
│ ├── DA_MULTITILE_PBS.m
│ └── OBSERVABLES
│ │ └── OBS_MULTITILE_SCF_1D.m
├── ENSEMBLE
│ ├── ENSEMBLE_MULTITILE_ESA_CCI.m
│ └── ENSEMBLE_MULTITILE_general.m
├── FORCING
│ ├── FORCING_MULTITILE_seb_CCI.m
│ └── POST_PROC
│ │ ├── apply_anomaly.m
│ │ ├── get_snowfall_melt.m
│ │ ├── merge_MODIS_ERA.m
│ │ ├── merge_MODIS_ERA_multiTile.m
│ │ ├── statistical_downscaling_MODIS.m
│ │ └── time_average_temperature.m
├── GRID
│ └── GRID_MULTITILE_user_defined.m
├── GROUND
│ ├── GROUND_MULTITILE_ESA_CCI.m
│ ├── GROUND_MULTITILE_ESA_CCI_SEB.m
│ └── compiled
│ │ ├── GROUND_MULTITILE_ESA_CCI_compiled.m
│ │ ├── advance_E_compiled.m
│ │ ├── coder_commands.m
│ │ ├── compact_windDrift_compiled.m
│ │ ├── dE_dt_compiled.m
│ │ ├── get_Tground_compiled.m
│ │ ├── get_boundary_condition_u_compiled.m
│ │ ├── thermCond_compiled.m
│ │ ├── thermCond_eff_compiled.m
│ │ └── thermCond_snow_compiled.m
├── INIT_STEADY_STATE
│ └── TTOP_MULTITILE_GlobPF.m
├── OUT
│ ├── OUT_ESA_CCI_FDD_TDD.m
│ ├── OUT_MULTITILE_ESA_CCI_netcdf.m
│ └── OUT_MULTITILE_ESA_CCI_netcdf_monthly.m
├── RUN_INFO
│ ├── RUN_ESA_CCI_MatlabMPI.m
│ ├── RUN_ESA_CCI_NMPI.m
│ ├── RUN_ESA_CCI_slurmArray.m
│ ├── RUN_ESA_CCI_slurmArray_update.m
│ └── assign_run_info_properties
│ │ └── ESA_CCI_global_run_MODIS_deg.m
├── SPATIAL_REFERENCE
│ ├── COORDINATES_FROM_FILE_CCI.m
│ ├── N_HEMISPHERE.m
│ ├── N_HEMISPHERE_MODIS.m
│ └── POSTPROC_COORDINATES_FROM_FILE_CCI.m
├── STRATIGRAPHY
│ ├── STRAT_layers_ESA_CCI2.m
│ ├── STRAT_layers_confining_stratigraphies.m
│ └── STRAT_two_confining_stratigraphies.m
└── TILE
│ ├── MULTITILE_ESA_CCI.m
│ ├── MULTITILE_ESA_CCI2.m
│ └── MULTITILE_ESA_CCI_DA.m
├── IO
├── CLUSTERING
│ ├── CLUSTER_RAW_VARIABLES.m
│ ├── CLUSTER_SLOPE_ASPECT.m
│ └── K_MEANS.m
├── COORDINATE_SYSTEM
│ ├── ASSIGN_TILE_PROPERTIES
│ │ ├── tag_out_w_run_number.m
│ │ ├── update_general.m
│ │ └── update_one2one.m
│ ├── COORDINATES_FROM_FILE.m
│ ├── LAT_LON.m
│ ├── LIST_OF_POINTS.m
│ ├── MASK
│ │ ├── MASK_altitude.m
│ │ ├── MASK_fixed_pixel_number.m
│ │ ├── MASK_fraction.m
│ │ ├── MASK_kml.m
│ │ ├── MASK_kml_old.m
│ │ ├── MASK_point_selection.m
│ │ └── MASK_point_selection_old.m
│ └── POINT
│ │ ├── POINT_3D_SIMPLE.m
│ │ ├── POINT_DEM.m
│ │ ├── POINT_SIMPLE.m
│ │ └── POINT_SLOPE.m
├── DATA_ASSIMILATION
│ ├── DA_iterative_particle_batch_smoother.m
│ ├── DA_particle_batch_smoother.m
│ ├── DA_particle_filter.m
│ ├── ENSEMBLE_forcing_seb.m
│ ├── ENSEMBLE_general.m
│ └── OBSERVABLES
│ │ └── OBS_snow_covered_fraction_1D.m
├── DATA_PROVIDER
│ ├── DEM.m
│ └── DEM_BASE.m
├── FORCING
│ ├── ENSEMBLE
│ │ ├── FORCING_seb_mat_ensemble.m
│ │ ├── FORCING_slope_seb_mat_ensemble.m
│ │ ├── FORCING_slope_seb_surfaceLevel_ensemble.m
│ │ ├── FORCING_slope_seb_surfaceLevel_slice_ensemble.m
│ │ ├── FORCING_slope_seb_topoScale_ensemble.m
│ │ ├── FORCING_slope_seb_topoScale_slice_ensemble.m
│ │ └── PERTURB_forcing_simple.m
│ ├── FORCING_Tair_Tlb_fixed_mat.m
│ ├── FORCING_discontinued
│ │ ├── @FORCING_seb_salt
│ │ │ ├── FORCING_seb_salt.m
│ │ │ ├── interpolate_forcing.m
│ │ │ └── load_forcing_from_mat.m
│ │ ├── FORCING_Tair_Tlb_fixed.m
│ │ ├── FORCING_do_nothing.m
│ │ ├── FORCING_harmonic_Tair.m
│ │ ├── FORCING_read_out.m
│ │ ├── FORCING_seb.m
│ │ ├── FORCING_seb_loop.m
│ │ ├── FORCING_seb_ncFromTopoScale.m
│ │ ├── FORCING_seb_nc_PCCH.m
│ │ ├── FORCING_seb_vegetation.m
│ │ ├── FORCING_slope_forest_seb_readNc.m
│ │ ├── FORCING_slope_forest_seb_readNc2.m
│ │ ├── FORCING_slope_seb.m
│ │ ├── FORCING_slope_seb_readNc.m
│ │ ├── FORCING_tair_precip.m
│ │ ├── FORCING_ubT.m
│ │ └── FORCING_ubT_lbT_fixed.m
│ ├── FORCING_harmonic_Tair.m
│ ├── FORCING_seb_mat.m
│ ├── FORCING_slope_seb_mat.m
│ ├── FORCING_slope_seb_surfaceLevel.m
│ ├── FORCING_slope_seb_surfaceLevel_slice.m
│ ├── FORCING_slope_seb_topoScale.m
│ ├── FORCING_slope_seb_topoScale_slice.m
│ ├── FORCING_tair_precip_mat.m
│ ├── FORCING_ubT.m
│ ├── FORCING_ubT_lbT_fixed.m
│ ├── POST_PROC
│ │ ├── bias_correct_BASE.m
│ │ ├── compute_time_average_ensemble.m
│ │ ├── condense_precip.m
│ │ ├── convert2ESA_CCI.m
│ │ ├── convert2ESA_CCI_ensemble.m
│ │ ├── remove_melt_event.m
│ │ └── time_average.m
│ └── TIER1
│ │ ├── FORCING_base.m
│ │ ├── PROCESS_FORCING_topoScale.m
│ │ ├── READ_FORCING_NC.m
│ │ ├── READ_FORCING_base.m
│ │ └── READ_FORCING_mat.m
├── GRID
│ └── GRID_user_defined.m
├── INIT_STEADY_STATE
│ ├── INIT_TTOP_from_forcing.m
│ └── INIT_TTOP_from_out.m
├── OUT
│ ├── OUT_FDD_TDD.m
│ ├── OUT_MB.m
│ ├── OUT_SEB.m
│ ├── OUT_TwaterIce.m
│ ├── OUT_all.m
│ ├── OUT_all_lateral.m
│ ├── OUT_all_lateral_BGC.m
│ ├── OUT_all_lateral_BGC2.m
│ ├── OUT_all_lateral_BGC3.m
│ ├── OUT_all_lateral_CG3style.m
│ ├── OUT_all_lateral_DA.m
│ ├── OUT_all_lateral_STORE4READ.m
│ ├── OUT_all_lateral_averages.m
│ ├── OUT_all_lateral_vegetation.m
│ ├── OUT_all_multiTile_lateral.m
│ ├── OUT_all_tagged.m
│ ├── OUT_do_nothing.m
│ ├── OUT_last_timestep.m
│ ├── OUT_regridded.m
│ └── OUT_regridded_FCI.m
├── PROVIDER
│ ├── BASE_PROVIDER.m
│ ├── PROVIDER.m
│ ├── PROVIDER_EXCEL.m
│ ├── PROVIDER_EXCEL3D.m
│ ├── PROVIDER_EXCEL_edu.m
│ ├── PROVIDER_MAT.m
│ ├── PROVIDER_YAML.m
│ ├── PROVIDER_YAML3D.m
│ ├── check_if_CONST_assigned.m
│ └── check_if_PARA_assigned.m
├── RUN_INFO
│ ├── RUN_1D_POINT.m
│ ├── RUN_1D_POINT_SPINUP.m
│ ├── RUN_3D_POINT.m
│ ├── RUN_ENSEMBLE.m
│ ├── RUN_SPATIAL_SPINUP.m
│ └── RUN_SPATIAL_SPINUP_CLUSTERING.m
├── STRATIGRAPHY_CLASSES
│ └── STRAT_classes.m
├── STRATIGRAPHY_STATVAR
│ ├── STRAT_ensemble_two_confining_stratigraphies.m
│ ├── STRAT_layers.m
│ ├── STRAT_layers2.m
│ ├── STRAT_linear.m
│ └── STRAT_linear2.m
├── TILE
│ ├── TILE_1D_DA.m
│ ├── TILE_1D_standard.m
│ ├── TILE_1D_standard2.m
│ └── TILE_forcing_preproc.m
├── TILE_BUILDER
│ ├── new_init.m
│ ├── new_init_steady_state.m
│ ├── new_init_with_TTOP.m
│ ├── restart_OUT_last_timestep.m
│ ├── restart_from_OUT_update_classes.m
│ ├── update_forcing_out.m
│ └── update_forcing_out_with_TTOP.m
└── UNIT_CONVERSION
│ └── UNIT_CONVERSION_standard.m
├── LATERAL
├── BASE
│ ├── BASE_LATERAL.m
│ ├── LATERAL_1D.m
│ └── LATERAL_3D.m
├── LAT1D
│ ├── LAT_HEAT.m
│ ├── LAT_OVERLAND_FLOW.m
│ ├── LAT_REMOVE_SUBSURFACE_WATER.m
│ ├── LAT_REMOVE_SURFACE_WATER.m
│ ├── LAT_SEEPAGE_FACE_WATER.m
│ └── LAT_WATER_RESERVOIR.m
└── LAT3D
│ ├── LAT3D_HEAT.m
│ ├── LAT3D_REMOVE_SURFACE_WATER.m
│ ├── LAT3D_SNOW_CROCUS.m
│ ├── LAT3D_SNOW_CROCUS_snow_dump.m
│ ├── LAT3D_SNOW_CROCUS_snow_dump2.m
│ ├── LAT3D_SNOW_CROCUS_snow_dump2_old.m
│ ├── LAT3D_WATER.m
│ ├── LAT3D_WATER_OVERLAND_FLOW.m
│ ├── LAT3D_WATER_RESERVOIR.m
│ ├── LAT3D_WATER_SEEPAGE_FACE.m
│ ├── LAT3D_WATER_UNCONFINED_AQUIFER.m
│ ├── LAT3D_WATER_UNCONFINED_AQUIFER2.m
│ ├── LAT3D_WATER_UNCONFINED_AQUIFER_OVERLAND_FLOW.m
│ └── LAT3D_WATER_UNCONFINED_AQUIFER_RICHARDS_EQ.m
├── TIER_0_base
├── BASE.m
├── Bottom.m
├── IA_BASE.m
└── Top.m
├── TIER_1_processes
├── AIR_CONVECTION.m
├── BGC
│ ├── PEAT_ACCUMULATION.m
│ └── PEAT_DECOMPOSE.m
├── BGC_CLM4.m
├── CG_LITE.m
├── FLIP_FLOP.m
├── FREEZE_CURVE.m
├── FREEZE_CURVE_DallAmico_do_not_use.m
├── FREEZE_CURVE_KarraPainter.m
├── FREEZE_CURVE_Painter_do_no_use.m
├── HEAT_CONDUCTION.m
├── HEAT_FLUXES_LATERAL.m
├── INTERACTION
│ ├── IA_BGC.m
│ ├── IA_HEAT.m
│ ├── IA_SALT.m
│ ├── IA_SEB.m
│ ├── IA_SEB_backup.m
│ ├── IA_VEGETATION_CLM5.m
│ ├── IA_WATER.m
│ └── get_water_transpiration.m
├── LAKE.m
├── LB_TEMPERATURE_FORCING.m
├── REGRID.m
├── SALT.m
├── SEB.m
├── SEB2.m
├── SEB_VEGETATION.m
├── SNOW.m
├── SNOW_FLUXES_LATERAL.m
├── SNOW_MELTFACTOR.m
├── SOIL_GAS.m
├── SOIL_MECHANICS.m
├── UB_TEMPERATURE_FORCING.m
├── VEGETATION.m
├── WATER_FLUXES.m
├── WATER_FLUXES_LATERAL.m
└── canopy_resistances_CLM5_Stewart.m
├── TIER_2_full_classes
├── BGC
│ ├── BGC_Frolking_PEAT.m
│ ├── BGC_LPJ_PEAT.m
│ ├── GROUND_all_constant.m
│ ├── GROUND_all_constant_BGC.m
│ ├── GROUND_freezeC_bucketW_Xice_seb_snow_BGC.m
│ ├── GROUND_store_flip_flop_singleClass_BGC.m
│ ├── IA_BGC_Xice.m
│ ├── IA_BGC_read_statvar_from_out.m
│ ├── IA_BGC_simple.m
│ ├── IA_DO_NOTHING.m
│ ├── READ_STATVAR_FROM_OUT.m
│ ├── READ_STATVAR_FROM_OUT_BGC.m
│ └── trash
│ │ ├── BGC_CLASS_TEMPLATE.m
│ │ ├── BGC_Frolking_PEAT2.m
│ │ ├── anpp_whyme.mat
│ │ ├── anpp_whyme.out
│ │ └── old_GROUND_freezeC_bucketW_Xice_seb_BGC.m
├── FLIP_FLOP
│ └── GROUND_store_flip_flop_singleClass.m
├── GLACIER_freeW_seb.m
├── GROUND_LITE1.m
├── GROUND_TTOP_simple.m
├── GROUND_TTOP_simple2.m
├── GROUND_fcSimple_salt_seb.m
├── GROUND_fcSimple_salt_ubT.m
├── GROUND_fcSimple_salt_ubtf.m
├── GROUND_freeW_bucketW_convection_seb.m
├── GROUND_freeW_bucketW_seb.m
├── GROUND_freeW_seb.m
├── GROUND_freeW_seb_verticalWall.m
├── GROUND_freeW_ubT.m
├── GROUND_freeW_ubtf.m
├── GROUND_freeW_ubtf_lbtf.m
├── GROUND_freezeC_RichardsEqW_ExperimentHansen.m
├── GROUND_freezeC_RichardsEqW_Xice_seb.m
├── GROUND_freezeC_RichardsEqW_Xice_seb_OLD.m
├── GROUND_freezeC_RichardsEqW_seb.m
├── GROUND_freezeC_RichardsEqW_seb_pressure.m
├── GROUND_freezeC_bucketW_Xice_seb.m
├── GROUND_freezeC_bucketW_seb.m
├── GROUND_freezeC_seb.m
├── GROUND_freezeC_ubT.m
├── GROUND_house.m
├── GROUND_house_on_poles.m
├── INTERACTION
│ ├── IA_HEAT11.m
│ ├── IA_HEAT11_LAKE.m
│ ├── IA_HEAT11_SALT01.m
│ ├── IA_HEAT11_SALT10.m
│ ├── IA_HEAT11_WATER01.m
│ ├── IA_HEAT11_WATER10.m
│ ├── IA_HEAT11_WATER10_LAKE.m
│ ├── IA_HEAT11_WATER11.m
│ ├── IA_HEAT11_WATER11_LAKE.m
│ ├── IA_HEAT11_WATER11_LAKE_LAKE_discontinued.m
│ ├── IA_HEAT11_WATER11_LAKE_SNOW_discontinued.m
│ ├── IA_HEAT11_WATER11_LAKE_XICE.m
│ ├── IA_HEAT11_WATER11_RichardsEq_LAKE.m
│ ├── IA_HEAT11_WATER11_RichardsEq_LAKE_XICE.m
│ ├── IA_HEAT11_WATER11_RichardsEq_SNOW.m
│ ├── IA_HEAT11_WATER11_RichardsEq_SNOW_XICE.m
│ ├── IA_HEAT11_WATER11_SNOW.m
│ ├── IA_HEAT11_WATER11_SNOW_LAKE.m
│ ├── IA_HEAT11_WATER11_SNOW_XICE.m
│ ├── IA_HEAT_TTOP.m
│ ├── IA_LAKE_simple_frozen_unfrozen.m
│ ├── IA_MULTI_TILE10.m
│ ├── IA_SEB11_vegetation_NOT_USED.m
│ ├── IA_SEB_vegetation_CLM5.m
│ ├── IA_SEB_vegetation_CLM5_GROUND_Xice_snow.m
│ ├── IA_SEB_vegetation_CLM5_GROUND_snow.m
│ ├── IA_SEB_vegetation_CLM5_SNOW.m
│ ├── IA_SEB_vegetation_CLM5_snow_GROUND_Xice_snow.m
│ ├── IA_thermRadiation11.m
│ ├── get_IA_class.m
│ ├── get_IA_class_Juditha.m
│ ├── get_IA_class_discontinued.m
│ ├── interaction_matrix.xlsx
│ └── ~$interaction_matrix.xlsx
├── LAKE_simple_bucketW_seb
│ ├── LAKE_simple_bucketW_seb.m
│ └── LAKE_simple_unfrozen_bucketW_seb.m
├── LAKE_simple_seb
│ ├── LAKE_simple_seb.m
│ └── LAKE_simple_unfrozen_seb.m
├── SNOW_crocus2_bucketW_seb.m
├── SNOW_crocus_bucketW_seb.m
├── SNOW_simple_bucketW_seb.m
├── SNOW_simple_seb.m
├── SNOW_simple_ubT.m
├── SNOW_simple_ubtf_mf.m
├── VEGETATION
│ ├── @VEGETATION_ml_canopy
│ │ ├── VEGETATION_ml_canopy.m
│ │ ├── private
│ │ │ ├── CLM_Vegetation.m
│ │ │ ├── CanopyEvaporation.m
│ │ │ ├── CanopyFluxesMultilayer.m
│ │ │ ├── CanopyFluxesSum.m
│ │ │ ├── CanopyInterception.m
│ │ │ ├── CanopyNitrogenProfile.m
│ │ │ ├── CanopyTurbulence.m
│ │ │ ├── CiFunc.m
│ │ │ ├── CiFuncGs.m
│ │ │ ├── GetBeta.m
│ │ │ ├── GetPrSc.m
│ │ │ ├── GetPsiRSL.m
│ │ │ ├── GoudriaanRadiation.m
│ │ │ ├── LatVap.m
│ │ │ ├── LeafBoundaryLayer.m
│ │ │ ├── LeafFluxes.m
│ │ │ ├── LeafHeatCapacity.m
│ │ │ ├── LeafPhotosynthesis.m
│ │ │ ├── LeafTemperatureMod.m
│ │ │ ├── LeafTranspiration.m
│ │ │ ├── LeafWaterPotential.m
│ │ │ ├── LongwaveRadiation.m
│ │ │ ├── LookupPsihat.m
│ │ │ ├── LookupPsihatINI.m
│ │ │ ├── NormanRadiation.m
│ │ │ ├── ObuFunc.m
│ │ │ ├── PhotosynthesisParam.m
│ │ │ ├── PlantResistance.m
│ │ │ ├── Satvap.m
│ │ │ ├── SetUpCanopy.m
│ │ │ ├── SetUpForcing.m
│ │ │ ├── SoilFluxesMultilayer.m
│ │ │ ├── SoilResistance.m
│ │ │ ├── SolarAzEl.m
│ │ │ ├── SolarRadiation.m
│ │ │ ├── StomataEfficiency.m
│ │ │ ├── StomataFluxes.m
│ │ │ ├── StomataOptimization.m
│ │ │ ├── TleafFunc.m
│ │ │ ├── brent_root.m
│ │ │ ├── canopy_fluxes_multilayer.m
│ │ │ ├── data.txt
│ │ │ ├── filter_exposedvegp.m
│ │ │ ├── ft.m
│ │ │ ├── fth.m
│ │ │ ├── fth25.m
│ │ │ ├── fth25_g.m
│ │ │ ├── get_F_lb.m
│ │ │ ├── hybrid_root.m
│ │ │ ├── initialize_atmos.m
│ │ │ ├── initialize_canopy.m
│ │ │ ├── initialize_flux.m
│ │ │ ├── initialize_forcing.m
│ │ │ ├── initialize_leaf.m
│ │ │ ├── initialize_mlcanopyinst.m
│ │ │ ├── initialize_params.m
│ │ │ ├── initialize_pftcon.m
│ │ │ ├── initialize_physcon.m
│ │ │ ├── initialize_soil.m
│ │ │ ├── phi_c_monin_obukhov.m
│ │ │ ├── phi_m_monin_obukhov.m
│ │ │ ├── plots.m
│ │ │ ├── psi_c_monin_obukhov.m
│ │ │ ├── psi_m_monin_obukhov.m
│ │ │ ├── psihatH.dat
│ │ │ ├── psihatM.dat
│ │ │ ├── quadratic.m
│ │ │ ├── scalar_profile.m
│ │ │ ├── set_up_canopy.m
│ │ │ ├── set_up_canopy_summer.m
│ │ │ ├── set_up_canopy_winter.m
│ │ │ ├── set_up_forcing.m
│ │ │ ├── shell_001.m
│ │ │ ├── surface_energy_balance.m
│ │ │ ├── test_leaf_ET_sebas.m
│ │ │ ├── tridiagonal_solver.m
│ │ │ └── untitled.fig
│ │ ├── psihatH.dat
│ │ └── psihatM.dat
│ ├── GROUND_freezeC_RichardsEqW_seb_vegetation.m
│ ├── GROUND_freezeC_RichardsEqW_seb_vegetation_snow.m
│ ├── GROUND_freezeC_bucketW_seb_vegetation.m
│ ├── IA_ml_canopy_GROUND.m
│ ├── IA_ml_canopy_SURFACE.m
│ └── SNOW_crocus_bucketW_seb_vegetation.m
└── VEGETATION_CLM5_seb.m
└── TIER_3
├── FLIP_FLOP
├── GROUND_freezeC_bucketW_Xice_seb_snow_BGC_FLIP_FLOP.m
└── GROUND_freezeC_bucketW_Xice_seb_snow_FLIP_FLOP.m
├── MULTI_TILE
├── GROUND_multi_tile.m
├── GROUND_multi_tile2.m
└── GROUND_multi_tile2_Cas.m
└── SNOW
├── GLACIER_freeW_seb_snow.m
├── GROUND_fcSimple_salt_seb_snow.m
├── GROUND_fcSimple_salt_ubT_snow.m
├── GROUND_fcSimple_salt_ubtf_snow.m
├── GROUND_freeW_bucketW_convection_seb_snow.m
├── GROUND_freeW_bucketW_seb_snow.m
├── GROUND_freeW_seb_snow.m
├── GROUND_freeW_ubT_snow.m
├── GROUND_freeW_ubtf_snow.m
├── GROUND_freezeC_RichardsEqW_Xice_seb_snow.m
├── GROUND_freezeC_RichardsEqW_seb_pressure_snow.m
├── GROUND_freezeC_RichardsEqW_seb_snow.m
├── GROUND_freezeC_bucketW_Xice_seb_snow.m
├── GROUND_freezeC_bucketW_seb_snow.m
├── GROUND_freezeC_seb_snow.m
├── GROUND_freezeC_ubT_snow.m
├── LAKE_simple_bucketW_seb_snow.m
├── LAKE_simple_seb_snow.m
└── VEGETATION_CLM5_seb_snow.m
/.gitignore:
--------------------------------------------------------------------------------
1 | ##---------------------------------------------------
2 | ## Remove autosaves generated by the Matlab editor
3 | ## We have git for backups!
4 | ##---------------------------------------------------
5 |
6 | # default forcing directory
7 | ./forcing/*
8 |
9 | # default output directory
10 | ./results/*
11 |
12 | # mat-files
13 | *.mat
14 |
15 | # compliled UML diagrams
16 | ./UMLs/*.puml
17 | ./UMLs/*.svg
18 |
19 | # ESA_CCI
20 | ./source/ESA_CCI/*
21 | ./discontinued/*
22 |
23 |
24 | # ESA_CCI2
25 | source/ESA_CCI2/*
26 | source/ESA_CCI/GROUND/compiled/codegen/*
27 |
28 | # Windows default autosave extension
29 | *.asv
30 |
31 | # OSX / *nix default autosave extension
32 | *.m~
33 |
34 | # Compiled MEX binaries (all platforms)
35 | *.mex*
36 |
37 | # Compiled c code
38 | *.c*
39 |
40 | # Compiled c code
41 | *.h*
42 |
43 | # Simulink Code Generation
44 | slprj/
45 |
46 | # Session info
47 | octave-workspace
48 |
49 | # Simulink autosave extension
50 | .autosave
51 | source.zip
52 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CryoGrid community model
2 |
3 | This is the community version of *CryoGrid*, a numerical model to investigate land surface processes in the terrestrial cryosphere. This version of *CryoGrid* is implemented in MATLAB.
4 |
5 | *Note: This is the latest development of the CryoGrid model family. It comprises the functionalities of previous versions including [CryoGrid3](https://github.com/CryoGrid/CryoGrid3), which is no longer encouraged to be used.*
6 |
7 | ## Documentation
8 |
9 | The paper ["The CryoGrid community model - a multi-physics toolbox for climate-driven simulations in the terrestrial cryosphere"](https://doi.org/10.5194/gmd-16-2607-2023) in published in Geoscientific Model Development and contains a description of the model and instructions to run it (Supplements 1, 3).
10 |
11 | ## Getting started
12 |
13 | Both [CryoGridCommunity_source](https://github.com/CryoGrid/CryoGridCommunity_source) and [CryoGridCommunity_run](https://github.com/CryoGrid/CryoGridCommunity_run) are required. See [CryoGridCommunity_run](https://github.com/CryoGrid/CryoGridCommunity_run) for details.
14 | An instruction video on downloading the CryoGrid community model and running simple simulations is available here: https://www.youtube.com/watch?v=L1GIurc5_J4&t=372s
15 | The parameter files and model forcing data for the simple simulations from the video can be downloaded here: http://files.artek.byg.dtu.dk/files/cryogrid/CryoGridExamples/CryoGrid_simpleExamples.zip
16 |
17 | ## Get involved
18 |
19 | There is an [email group](https://groups.google.com/g/cryogrid) for news, (high-level) discussions and invitation to the annual hackathon, as well as a [slack](https://join.slack.com/t/cryogrid/shared_invite/zt-2487oq3o5-ghOQCw2rLimIk13xft27ZQ) for debugging, (low-level) discussions, community building and other things CryoGrid-related!
20 |
--------------------------------------------------------------------------------
/UMLs/create_all_uml.m:
--------------------------------------------------------------------------------
1 | create_uml_tier1;
2 | create_uml_tier23;
3 | create_uml_forcing;
4 | create_index;
5 |
--------------------------------------------------------------------------------
/UMLs/create_index.m:
--------------------------------------------------------------------------------
1 | %==========================================================================
2 | % Generate index.html for UML files
3 | % T. Ingemann-Nielsen, November 2020
4 | %==========================================================================
5 |
6 |
7 | filename = 'index.html';
8 |
9 | files = rdir('*.svg');
10 |
11 | tier1_classes = files(contains({files.name}, 'TIER1'));
12 | tier2_classes = files(contains({files.name}, 'TIER2'));
13 | tier3_classes = files(contains({files.name}, 'TIER3'));
14 | forcing_classes = files(contains({files.name}, 'FORCING'));
15 |
16 | % file_list, Section_name, Description
17 | sections = {{{}, 'TIER 0', 'Tier 0 classes inherit only from intrinsic Matlab classes.'}, % No classes listed, thus empty struct
18 | {tier1_classes, 'TIER 1', 'Tier 1 classes inherit from Tier 0 classes and are not full functioning classes.'},
19 | {tier2_classes, 'TIER 2', ''},
20 | {tier3_classes, 'TIER 3', ''},
21 | {forcing_classes, 'FORCING', ''},
22 | };
23 |
24 | header = {
25 | ''
26 | ''
27 | '
'
28 | 'CryoGrid Class Ineritance Hierachies'
29 | ''
37 | ''
38 | ''
39 | ''
40 | 'CryoGrid Class Ineritance Hierachies
'
41 | '
'};
42 |
43 | nbsp = '
';
44 | link = '%s
';
45 |
46 | heading = {
47 | '\n'
48 | '%s
\n'};
49 |
50 | footer = {
51 | ''
52 | ''
53 | ''};
54 |
55 | fid = fopen(filename,'w');
56 | fprintf(fid, '%s\n', header{:});
57 |
58 | fprintf(fid, 'Contents
\n');
59 | for m = 1:length(sections)
60 | fprintf(fid, 'Jump to: %s
\n', sections{m}{2}, sections{m}{2});
61 | end
62 | fprintf(fid, '%s\n', nbsp);
63 |
64 | for m = 1:length(sections)
65 | fprintf(fid, heading{1}, sections{m}{2}, sections{m}{2});
66 | fprintf(fid, heading{2}, sections{m}{3});
67 |
68 | classes = sections{m}{1};
69 | if ~isempty(classes)
70 | for k = 1:length(classes)
71 | [filepath,name,ext] = fileparts(classes(k).name);
72 | fprintf(fid, link, ['.\' name ext], name);
73 | end
74 | end
75 | fprintf(fid, '%s\n', nbsp);
76 | end
77 |
78 | fprintf(fid, '%s\n', footer{:});
79 |
80 | fclose(fid) ;
--------------------------------------------------------------------------------
/UMLs/localize_svgs.m:
--------------------------------------------------------------------------------
1 | % localize all relative links in svg files to absolute links relative to
2 | % the current install.
3 |
4 | files = rdir('*.svg');
5 |
6 | for k = 1:length(files)
7 | disp(['Localizing file: ' files(k).name]);
8 | relative2absolute_svglinkpath(files(k).name); % Make absolute paths from relative paths (like '../modules/*')
9 | absolute2absolute_svglinkpath(files(k).name); % Replace all absolute paths with new absolute paths (to be sure all paths are correct)
10 | end
--------------------------------------------------------------------------------
/UMLs/open_index.m:
--------------------------------------------------------------------------------
1 | % Open index in matlab web browser, to enable links to code
2 | [filepath,name,ext] = fileparts(mfilename('fullpath'));
3 | web('index.html')
4 |
5 |
6 |
7 |
8 | function absolute2relative_path(graphic_file)
9 | s=importdata(graphic_file);
10 |
11 | expr_line = "matlab:matlab.desktop.editor.openAndGoToLine\(([^),]+),([^),]+)\)";
12 | expr_func = "matlab:matlab.desktop.editor.openAndGoToFunction\(([^),]+),([^),]+)\)";
13 |
14 | for m = 1:length(s)
15 | [startID, endID,tokens, matches] = regexp(s{m},expr_line,'start','end','tokens','match');
16 | %disp(['Matches in line: ' num2str(length(matches))]);
17 |
18 | for n = 1:length(matches)
19 | mstr = matches{n};
20 |
21 | cs = {tokens{n}{1}(2:end-1); pwd};
22 | Schar = char(cs(:));
23 | b = diff(Schar, 1, 1) == 0;
24 | pstr = tokens{n}{1}(2:end-1);
25 | cpath = pstr(find(b));
26 |
27 | mstr2 = strrep(mstr,tokens{n}{1}, ['fullfile(pwd, ''' strrep(pstr, cpath, '..\') ''')']);
28 |
29 | s{m} = strrep(s{m}, mstr, mstr2);
30 | end
31 |
32 | [startID, endID,tokens, matches] = regexp(s{m},expr_func,'start','end','tokens','match');
33 | %disp(['Matches in line: ' num2str(length(matches))]);
34 |
35 | for n = 1:length(matches)
36 | mstr = matches{n};
37 |
38 | cs = {tokens{n}{1}(2:end-1); pwd};
39 | Schar = char(cs(:));
40 | b = diff(Schar, 1, 1) == 0;
41 | pstr = tokens{n}{1}(2:end-1);
42 | cpath = pstr(find(b));
43 |
44 | mstr2 = strrep(mstr,tokens{n}{1}, ['fullfile(pwd, ''' strrep(pstr, cpath, '..\') ''')']);
45 |
46 | s{m} = strrep(s{m}, mstr, mstr2);
47 | end
48 |
49 | end
50 |
51 |
52 | % Now we just need to save to text file
53 |
54 | fid = fop
55 | end
--------------------------------------------------------------------------------
/UMLs/readme.md:
--------------------------------------------------------------------------------
1 | # Inheritance diagrams
2 |
3 | This folder contains inheritance diagrams for selected CryoGrid classes. The diagrams are created in Unified Markup Language (UML), and exported to the Scalable Vector Graphics (SVG) format, which can be opened/viewed in all modern browsers.
4 |
5 | The folder contains both the *.uml and the *.svg versions.
6 | The diagrams contains links to the classes, methods and properties in the actual code.
7 | If the SVG diagrams are opened in the MatLab web browser, clicking one of these links will direct the MatLab editor to the corresponding definition in the code. This functionality only works in the MatLab browser, however, the diagrams are viewable in any browser.
8 |
9 | ## Getting started
10 |
11 | For the links in the diagrams to function, the *.svg files must contain absolute paths to the CryoGrid class files.
12 | Use the function `localize_svgs` in the 'UMLs' folder to convert all paths in all *.svg files to the correct path for your particular installation folder.
13 | The code currently assumes that the 'UMLs' folder is at the same level as the 'modules' folder:
14 |
15 | ```
16 | - My_CryoGrid_folder
17 | - ...
18 | - modules
19 | - UMLs
20 | - ...
21 | ```
22 |
23 | Navigate to the 'UMLs' folder in your MatLab console (or use the path selector):
24 |
25 | ```
26 | cd c:\path\to\cryogrid_install\UMLs
27 | ```
28 |
29 | The run the `localize_svgs` script:
30 |
31 | ```
32 | localize_svgs
33 | ```
34 |
35 | To open the Matlab browser and view the index of diagrams available, issue the following command in the Matlab console:
36 |
37 | ```
38 | open_index
39 | ```
40 |
41 | From the index, you can open inheritance diagrams of the classes you are interested in, and use the links in the diagrams to jump to the corresponding code in the MatLab editor.
42 |
43 | ## Commiting changes to the GIT repository
44 |
45 | When committing changes to the GIT repository, the links in the svg files should be relative (`./modules/*`), so that you do not commit links with the absolute paths to your particular install directory.
46 |
47 | For this purpose, a `relativize_svgs` script is supplied, which will convert absolute paths to relative paths in the svg files.
48 | Run this script before committing, or simply avoid to commit changes to the UML diagrams (unless you specifically changed them and know what you are doing).
49 |
50 | ## Regenerating inheritance diagrams
51 |
52 | For generation (regenerating) of the inheritance diagrams, use the script `create_all_uml`. This script will generate all the uml diagrams (which ones are defined in separate scripts), and regenerate the index file.
53 |
54 | The code relies on the toolbox `m2uml` and a `plantuml.jar` file.
55 | (Explanation of how to install and run this should be added...)
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/UMLs/relative2absolute_svglinkpath.m:
--------------------------------------------------------------------------------
1 | %==========================================================================
2 | % Converts links in svg files from relative ('../') to absolute paths
3 | % according to the current install location.
4 | % T. Ingemann-Nielsen, November 2020
5 | %==========================================================================
6 |
7 | function relative2absolute_svglinkpath(graphic_file)
8 | s=importdata(graphic_file);
9 |
10 | [filepath,name,ext] = fileparts(mfilename('fullpath'));
11 | pathparts = strsplit(filepath,filesep);
12 | basepath = strjoin(pathparts(1:end-1), filesep);
13 |
14 | expr_line = "matlab:matlab.desktop.editor.openAndGoToLine\(([^),]+),([^),]+)\)";
15 | expr_func = "matlab:matlab.desktop.editor.openAndGoToFunction\(([^),]+),([^),]+)\)";
16 |
17 | % iterate over all lines in file
18 | for m = 1:length(s)
19 | % find all links to a specific line in specific class
20 | [startID, endID,tokens, matches] = regexp(s{m},expr_line,'start','end','tokens','match');
21 |
22 | % iterate over all links found
23 | for n = 1:length(matches)
24 | mstr = matches{n}; % get the path of the file linked to
25 |
26 | pstr = tokens{n}{1}(2:end-1); % get the link path without quotes
27 |
28 | if startsWith(pstr, '..\')
29 | % Now replace the .. designator with the full path to the
30 | % modules directory and regenerate the full link
31 | % information
32 | mstr2 = strrep(mstr,tokens{n}{1}, ['''' basepath pstr(3:end) '''']);
33 |
34 | s{m} = strrep(s{m}, mstr, mstr2); % replace full link in line of file
35 | end
36 | end
37 |
38 | [startID, endID,tokens, matches] = regexp(s{m},expr_func,'start','end','tokens','match');
39 |
40 | % iterate over all links found
41 | for n = 1:length(matches)
42 | mstr = matches{n}; % get the path of the file linked to
43 |
44 | pstr = tokens{n}{1}(2:end-1); % get the link path without quotes
45 |
46 | if startsWith(pstr, '..\')
47 | % Now replace the .. designator with the full path to the
48 | % modules directory and regenerate the full link
49 | % information
50 | mstr2 = strrep(mstr,tokens{n}{1}, ['''' basepath pstr(3:end) '''']);
51 |
52 | s{m} = strrep(s{m}, mstr, mstr2); % replace full link in line of file
53 | end
54 | end
55 |
56 | end
57 |
58 |
59 | % Now we just need to save to text file
60 |
61 | fid = fopen(graphic_file,'w');
62 | fprintf(fid, '%s\n',s{:}) ;
63 | fclose(fid) ;
64 | end
--------------------------------------------------------------------------------
/UMLs/relativize_svgs.m:
--------------------------------------------------------------------------------
1 | % localize all relative links in svg files to absolute links relative to
2 | % the current install.
3 |
4 | files = rdir('*.svg');
5 |
6 | for k = 1:length(files)
7 | disp(['Converting to relative paths, file: ' files(k).name]);
8 | absolute2relative_svglinkpath(files(k).name);
9 | end
--------------------------------------------------------------------------------
/doc/CryoGridLogo_git.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/doc/CryoGridLogo_git.png
--------------------------------------------------------------------------------
/doc/VEGETATION_CLM5_SEB.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/doc/VEGETATION_CLM5_SEB.doc
--------------------------------------------------------------------------------
/notes_cryogrid_changes.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/notes_cryogrid_changes.pdf
--------------------------------------------------------------------------------
/source/+yaml/MIT-license.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 CTU in Prague and Energocentrum PLUS s.r.o.
2 |
3 | Permission is hereby granted, free of charge, to any person
4 | obtaining a copy of this software and associated documentation
5 | files (the "Software"), to deal in the Software without
6 | restriction, including without limitation the rights to use,
7 | copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following
10 | conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/source/+yaml/README.md:
--------------------------------------------------------------------------------
1 | yamlmatlab
2 | ----------
3 |
4 | This is a github copy of https://code.google.com/p/yamlmatlab/
5 | that has been packaged into +yaml namespace by Yauhen Yakimovich.
6 |
7 |
8 | Installation
9 | ------------
10 |
11 | Just add the codes and all subfolders to Matlab path by
12 |
13 | ```matlab
14 | addpath(genpath('path/to/codes'));
15 | ```
16 |
17 |
18 | Usage
19 | -----
20 |
21 | Reading in:
22 |
23 | ```matlab
24 | yaml_file = 'test.yaml';
25 | YamlStruct = yaml.ReadYaml(yaml_file);
26 | ```
27 |
28 | Writing out
29 |
30 | ```matlab
31 | x.name='Martin';
32 | yaml.WriteYaml('test.yaml',x)
33 | ```
34 |
35 |
36 | Main authors
37 | ------------
38 |
39 | * Jiri Cigler, Dept. of Control Engineering, CTU Prague http://support.dce.felk.cvut.cz/pub/ciglejir/
40 | * Jan Siroky, Energocentrum PLUS, s.r.o.
41 | * Pavel Tomasko, student at Faculty of Electrical Engineering, CTU Prague and Institute of Chemical Technology, Prague.
42 |
--------------------------------------------------------------------------------
/source/+yaml/ReadYaml.m:
--------------------------------------------------------------------------------
1 | function result = ReadYaml(filename, nosuchfileaction, makeords, treatasdata, dictionary)
2 | import yaml.*;
3 | if ~exist('nosuchfileaction','var')
4 | nosuchfileaction = 0;
5 | end;
6 | if ~ismember(nosuchfileaction,[0,1])
7 | error('nosuchfileexception parameter must be 0,1 or missing.');
8 | end;
9 | if ~exist('makeords','var')
10 | makeords = 0;
11 | end;
12 | if ~ismember(makeords,[0,1])
13 | error('makeords parameter must be 0,1 or missing.');
14 | end;
15 | if(~exist('treatasdata','var'))
16 | treatasdata = 0;
17 | end;
18 | if ~ismember(treatasdata,[0,1])
19 | error('treatasdata parameter must be 0,1 or missing.');
20 | end;
21 | ry = ReadYamlRaw(filename, 0, nosuchfileaction, treatasdata);
22 | ry = deflateimports(ry);
23 | if iscell(ry) && length(ry) == 1 && isstruct(ry{1}) && length(fields(ry{1})) == 1 && isfield(ry{1},'import')
24 | ry = ry{1};
25 | end;
26 | ry = mergeimports(ry);
27 | ry = doinheritance(ry);
28 | ry = makematrices(ry, makeords);
29 | if exist('dictionary','var')
30 | ry = dosubstitution(ry, dictionary);
31 | end;
32 | result = ry;
33 | clear global nsfe;
34 | end
35 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_import/file1.yaml:
--------------------------------------------------------------------------------
1 | f1a: 47
2 | f1b: 78
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_import/file2.yaml:
--------------------------------------------------------------------------------
1 | f2a: 99
2 | f2b: 111
3 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_import/file3.yaml:
--------------------------------------------------------------------------------
1 | f3a: 999
2 | f3b: 142
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_import/file4.yaml:
--------------------------------------------------------------------------------
1 | f4a: 123
2 | f4b: 456
3 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_import/import.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_import/import.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_import/import.yaml:
--------------------------------------------------------------------------------
1 | - import:
2 | - ../test_primitives/time.yaml
3 | - ../test_inheritance/inheritance.yaml
4 | #- ..\test_primitives\time_variants.yaml
5 | - import: [../test_primitives/matrices.yaml, ../test_primitives/sequence_mapping.yaml]
6 |
7 |
8 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_import/import_def.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_import/import_def.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_import/import_def.yaml:
--------------------------------------------------------------------------------
1 | import:
2 | - file1.yaml
3 | - file2.yaml
4 | - file3.yaml
5 | - file4.yaml
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_import/import_nonex.yaml:
--------------------------------------------------------------------------------
1 | import:
2 | - time_variants.yaml
3 | - inheritance.yaml
4 | - non-exists.yaml
5 | import: [matrices.yaml, sequence_mapping.yaml, non-ex.yaml]
6 |
7 |
8 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_inheritance/inheritance.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_inheritance/inheritance.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_inheritance/inheritance.yaml:
--------------------------------------------------------------------------------
1 | cars:
2 | - color: blue
3 | label: JJ-XX-1500
4 | parent:
5 | - manufacturer.skoda
6 | - insurance.mandatory.Allianz
7 | - insurance.optional.Kooperativa
8 |
9 | ins_note: IMPORTANT_1
10 | info: {aaa: 2}
11 |
12 | - color: red
13 | label: DD-XX-1500
14 | ins_note: IMPORTANT_2
15 | parent : [ manufacturer.audi, insurance.mandatory.Allianz ]
16 |
17 | manufacturer:
18 | skoda:
19 | established: cca 1900
20 | place: MB
21 | info:
22 | aaa: 1
23 | bbb: 11
24 | audi:
25 | established: cca 1900
26 | place: Germany
27 |
28 | insurance:
29 | mandatory:
30 | Allianz:
31 | ins_price: 4000
32 | ins_unit : CZK
33 | Kooperativa:
34 | ins_price: 4100
35 | ins_unit : CZK
36 | ins_note : umfty dumf
37 |
38 | optional:
39 | CP:
40 | ins_price: 1000 CZK
41 | Kooperativa:
42 | ins_price: 1100 CZK
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_inheritance/inheritance_loop.yaml:
--------------------------------------------------------------------------------
1 | # loop in inheritance
2 | students:
3 | s1: { name: jan, parent: students.s2}
4 | s2: { name: pepa, parent: students.s1}
5 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_inheritance/inheritance_multiple.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_inheritance/inheritance_multiple.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_inheritance/inheritance_multiple.yaml:
--------------------------------------------------------------------------------
1 | a:
2 | v1: 10
3 | parent: [b,c]
4 |
5 | b:
6 | w1: 111
7 | parent: d
8 |
9 | c:
10 | w2: 798
11 | parent: d
12 |
13 | d:
14 | x: 113
15 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_misc/bug6.yaml:
--------------------------------------------------------------------------------
1 | # http://code.google.com/p/yamlmatlab/issues/detail?id=6
2 | # read-in this file in windows like environment
3 | test:
4 | - [16.0, 2.0, 3.0, 13.0]
5 | - [5.0, 11.0, 10.0, 8.0]
6 | - [9.0, 7.0, 6.0, 12.0]
7 | - [4.0, 14.0, 15.0, 1.0]
8 |
9 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_misc/dos_CRLF.yaml:
--------------------------------------------------------------------------------
1 | american:
2 | - Boston Red Sox
3 | - Detroit Tigers
4 | - New York Yankees
5 | national:
6 | - New York Mets
7 | - Chicago Cubs
8 | - Atlanta Braves
9 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_misc/miscellaneous.yaml:
--------------------------------------------------------------------------------
1 | null: ~
2 | true: y
3 | false: n
4 | string: '12345'
5 | foo: [] # see http://code.google.com/p/yamlmatlab/issues/detail?id=5
6 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_misc/spec_chars_utf8.yaml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_misc/unix_LF.yaml:
--------------------------------------------------------------------------------
1 | american:
2 | - Boston Red Sox
3 | - Detroit Tigers
4 | - New York Yankees
5 | national:
6 | - New York Mets
7 | - Chicago Cubs
8 | - Atlanta Braves
9 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/floating_points.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_primitives/floating_points.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/floating_points.yaml:
--------------------------------------------------------------------------------
1 | canonical: 1.23015e+3
2 | exponential: 12.3015e+02
3 | sexagecimal: 20:30.15
4 | fixed: 1230.15
5 | negative_infinity: -.inf
6 | not_a_number: .NaN
7 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/indentation.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_primitives/indentation.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/indentation.yaml:
--------------------------------------------------------------------------------
1 | name: Mark McGwire
2 | accomplishment: >
3 | Mark set a major league
4 | home run record in 1998.
5 | stats: |
6 | 65 Home Runs
7 | 0.278 Batting Average
8 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/matrices.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_primitives/matrices.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/matrices.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | Matrix1: [[1, 5],[1 , 3]]
3 | Matrix2:
4 | - [2 , 3]
5 | - [4 , 5]
6 | ColVect:
7 | - [1]
8 | - [2]
9 | RowVect: [1, 2]
10 | ...
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/sequence_mapping.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_primitives/sequence_mapping.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/sequence_mapping.yaml:
--------------------------------------------------------------------------------
1 | sequence:
2 | -
3 | name: Mark McGwire
4 | hr: 65
5 | avg: 0.278
6 | -
7 | name: Sammy Sosa
8 | hr: [63, 43]
9 | avg:
10 | - 0.288
11 | - 12
12 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/simple.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_primitives/simple.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/simple.yaml:
--------------------------------------------------------------------------------
1 | - {name: John Smith, age: 33}
2 | - name: Mary Smith
3 | age: 27
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/time.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_primitives/time.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/time.yaml:
--------------------------------------------------------------------------------
1 | Data:
2 | B1_S_SW:
3 | [!!timestamp '2011-03-29T18:09:20.0000000+02:00', 23.80]
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/time_variants.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_primitives/time_variants.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/time_variants.yaml:
--------------------------------------------------------------------------------
1 | canonical: !!timestamp 2001-12-15T02:59:43.0Z
2 | iso8601: !!timestamp 2001-12-14t21:59:43.00-05:00
3 | spaced: !!timestamp 2001-12-14 21:59:43.00 -5
4 | date: !!timestamp 2002-12-14
5 | matrix:
6 | - [!!timestamp '2001-12-15T02:59:43.0Z', 1]
7 | - [!!timestamp '2001-12-15T03:59:43.0Z', 2]
8 |
9 |
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/usecase_struct_01.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/Tests/Data/test_primitives/usecase_struct_01.mat
--------------------------------------------------------------------------------
/source/+yaml/Tests/Data/test_primitives/whitespaces.yaml:
--------------------------------------------------------------------------------
1 | YAML: 1.0
2 | Image file: 00032009.jpg
3 | Contours count: 8
--------------------------------------------------------------------------------
/source/+yaml/Tests/selftest_report.html:
--------------------------------------------------------------------------------
1 | ::SELFTEST REPORT::Selftest report from:28-Nov-2012 15:17:38
test_ReadYaml
test_ReadYaml:
Passed test_RY_FloatingPoints:
Passed |
test_RY_Import:
Passed |
test_RY_ImportDef:
Passed |
test_RY_ImportNonex:
Passed |
test_RY_Indentation:
Passed |
test_RY_Inheritance:
Passed |
test_RY_InheritanceLoop:
Passed |
test_RY_InheritanceMultiple:
Passed |
test_RY_Matrices:
Passed |
test_RY_SequenceMapping:
Passed |
test_RY_Simple:
Passed |
test_RY_Time:
Passed |
test_RY_TimeVariants:
Passed |
test_RY_Whitespaces:
Passed |
test_RY_usecase_01:
Passed |
test_WriteYaml
test_WriteYaml:
Passed test_WY_ComplexStructure:
Passed |
test_WY_FloatingPoints:
Passed |
test_WY_Indentation:
Passed |
test_WY_Matrices:
Passed |
test_WY_SequenceMapping:
Passed |
test_WY_Simple:
Passed |
test_WY_Time:
Passed |
test_WY_usecase_01:
Failed, Wrong values loaded |
--------------------------------------------------------------------------------
/source/+yaml/Tests/test_WriteYaml.m:
--------------------------------------------------------------------------------
1 | function stat = test_WriteYaml()
2 |
3 | stat.ok = 1;
4 | stat.desc = '';
5 | try
6 | fprintf('Testing write ');
7 | stat.test_WY_Matrices = test_WY_Universal(PTH_PRIMITIVES(), 'matrices');
8 | fprintf('.');
9 | stat.test_WY_FloatingPoints = test_WY_Universal(PTH_PRIMITIVES(), 'floating_points');
10 | fprintf('.');
11 | stat.test_WY_Indentation = test_WY_Universal(PTH_PRIMITIVES(), 'indentation');
12 | fprintf('.');
13 | stat.test_WY_SequenceMapping = test_WY_Universal(PTH_PRIMITIVES(), 'sequence_mapping');
14 | fprintf('.');
15 | stat.test_WY_Simple = test_WY_Universal(PTH_PRIMITIVES(), 'simple');
16 | fprintf('.');
17 | stat.test_WY_Time = test_WY_Universal(PTH_PRIMITIVES(), 'time');
18 | fprintf('.');
19 | stat.test_WY_ComplexStructure = test_WY_Universal(PTH_IMPORT(), 'import');
20 | fprintf('.');
21 | stat.test_WY_usecase_01 = test_WY_Universal(PTH_PRIMITIVES(), 'usecase_struct_01');
22 | fprintf('.\n');
23 | catch
24 | stat.ok = 0;
25 | stat.desc = 'Program crash';
26 | end
27 |
28 | end
29 |
30 | function result = PTH_PRIMITIVES()
31 | result = sprintf('Data%stest_primitives%s',filesep,filesep);
32 | end
33 |
34 | function result = PTH_IMPORT()
35 | result = sprintf('Data%stest_import%s',filesep,filesep);
36 | end
37 |
38 | function result = PTH_INHERITANCE()
39 | result = sprintf('Data%stest_inheritance%s',filesep,filesep);
40 | end
41 |
42 | function stat = test_WY_Universal(path, filename)
43 | stat.ok = 1;
44 | stat.desc = '';
45 | try
46 | data = load([path, filesep, filename, '.mat']);
47 | WriteYaml('~temporary.yaml',data.testval);
48 | ry = ReadYaml('~temporary.yaml');
49 | if ~isequalwithequalnans(ry, data.testval)
50 | stat.desc = 'Wrong values loaded';
51 | stat.ok = 0;
52 | end;
53 | catch
54 | stat.ok = 0;
55 | stat.desc = 'Crash';
56 | end;
57 | end
--------------------------------------------------------------------------------
/source/+yaml/datadump.m:
--------------------------------------------------------------------------------
1 | function datadump(data)
2 | import yaml.*;
3 | recurse(data, 0, []);
4 | end
5 | function result = recurse(data, level, addit)
6 | import yaml.*;
7 | indent = repmat(' | ',1,level);
8 | if iscell(data) && ~ismymatrix(data)
9 | result = iter_cell(data, level, addit);
10 | elseif isstruct(data)
11 | result = iter_struct(data, level, addit);
12 | else
13 | fprintf([indent,' +-Some data: ']);
14 | disp(data);
15 | result = data;
16 | end;
17 | end
18 | function result = iter_cell(data, level, addit)
19 | import yaml.*;
20 | indent = repmat(' | ',1,level);
21 | result = {};
22 | fprintf([indent,'cell {\n']);
23 | for i = 1:length(data)
24 | result{i} = recurse(data{i}, level + 1, addit);
25 | end;
26 | fprintf([indent,'} cell\n']);
27 | end
28 | function result = iter_struct(data, level, addit)
29 | import yaml.*;
30 | indent = repmat(' | ',1,level);
31 | result = struct();
32 | fprintf([indent,'struct {\n']);
33 | for i = fields(data)'
34 | fld = char(i);
35 | fprintf([indent,' +-field ',fld,':\n']);
36 | result.(fld) = recurse(data.(fld), level + 1, addit);
37 | end;
38 | fprintf([indent,'} struct\n']);
39 | end
40 |
--------------------------------------------------------------------------------
/source/+yaml/deflateimports.m:
--------------------------------------------------------------------------------
1 | function result = deflateimports(r)
2 | import yaml.*;
3 | result = recurse(r, 0, []);
4 | end
5 | function result = recurse(data, level, addit)
6 | import yaml.*;
7 | if iscell(data) && ~ismymatrix(data)
8 | result = iter_cell(data, level, addit);
9 | elseif isstruct(data)
10 | result = iter_struct(data, level, addit);
11 | else
12 | result = data;
13 | end;
14 | end
15 | function result = iter_cell(data, level, addit)
16 | import yaml.*;
17 | result = {};
18 | icollect = {};
19 | ii = 1;
20 | for i = 1:length(data)
21 | datai = data{i};
22 | if issingleimport(datai)
23 | if ~iscell(datai.import)
24 | datai.import = {datai.import};
25 | end;
26 | for j = 1:length(datai.import)
27 | icollect{end + 1} = datai.import{j};
28 | end;
29 | else
30 | result{ii} = recurse(datai, level + 1, addit);
31 | ii = ii + 1;
32 | end;
33 | end;
34 | if ~isempty(icollect)
35 | result{end + 1} = struct('import',{icollect});
36 | end;
37 | end
38 | function result = iter_struct(data, level, addit)
39 | import yaml.*;
40 | result = struct();
41 | for i = fields(data)'
42 | fld = char(i);
43 | result.(fld) = recurse(data.(fld), level + 1, addit);
44 | end;
45 | end
46 | function result = issingleimport_all(r)
47 | import yaml.*;
48 | result = all(cellfun(@issingleimport, r));
49 | end
50 | function result = issingleimport(r)
51 | import yaml.*;
52 | result = isstruct(r) && length(fields(r)) == 1 && isfield(r, 'import');
53 | end
54 | function result = addall(list1, list2)
55 | import yaml.*;
56 | for i = 1:length(list2)
57 | list1{end + 1} = list2{i};
58 | end;
59 | result = list1;
60 | end
61 |
--------------------------------------------------------------------------------
/source/+yaml/doinheritance.m:
--------------------------------------------------------------------------------
1 | function result = doinheritance(r, tr)
2 | import yaml.*;
3 | if ~exist('tr','var')
4 | tr = r;
5 | end;
6 | result = recurse(r, 0, {tr});
7 | end
8 | function result = recurse(data, level, addit)
9 | import yaml.*;
10 | if iscell(data) && ~ismymatrix(data)
11 | result = iter_cell(data, level, addit);
12 | elseif isstruct(data)
13 | result = iter_struct(data, level, addit);
14 | else
15 | result = data;
16 | end;
17 | end
18 | function result = iter_cell(data, level, addit)
19 | import yaml.*;
20 | result = {};
21 | for i = 1:length(data)
22 | result{i} = recurse(data{i}, level + 1, addit);
23 | end;
24 | for i = 1:length(data)
25 | if isstruct(result{i}) && isfield(result{i}, kwd_parent())
26 | result{i} = inherit(result{i}, result{i}.(kwd_parent()), [], addit{1}, {}); % !!!
27 | end;
28 | end;
29 | end
30 | function result = iter_struct(data, level, addit)
31 | import yaml.*;
32 | result = data;
33 | for i = fields(data)'
34 | fld = char(i);
35 | result.(fld) = recurse(data.(fld), level + 1, addit);
36 | end;
37 | for i = fields(result)'
38 | fld = char(i);
39 | if isstruct(result.(fld)) && isfield(result.(fld), kwd_parent())
40 | result.(fld) = inherit(result.(fld), result.(fld).(kwd_parent()), [], addit{1}, {});
41 | end;
42 | end;
43 | end
44 | function result = inherit(child, parent_chr, container, oaroot, loc_imported)
45 | import yaml.*;
46 | result = child;
47 | if ~iscell(parent_chr)
48 | parent_chr = {parent_chr};
49 | end;
50 | for i = length(parent_chr):-1:1
51 | if contains(loc_imported, parent_chr{i})
52 | error('MATLAB:MATYAML:inheritedtwice',['Cyclic inheritance: ', parent_chr{i}]);
53 | end;
54 | try
55 | parentstruct = eval(['oaroot.',parent_chr{i}]);
56 | catch ex
57 | switch ex.identifier
58 | case {'MATLAB:nonExistentField', 'MATLAB:badsubscript'}
59 | error('MATLAB:MATYAML:NonExistentParent', ['Parent was not found: ',parent_chr{i}]);
60 | end;
61 | rethrow(ex);
62 | end;
63 | if isstruct(parentstruct) && isfield(parentstruct, kwd_parent())
64 | next_loc_imported = loc_imported;
65 | next_loc_imported{end + 1} = parent_chr{i};
66 | result = merge_struct(inherit(parentstruct, parentstruct.(kwd_parent()), [], oaroot, next_loc_imported), result, {'import'});
67 | end;
68 | result = merge_struct(parentstruct, result, {'import'});
69 | end;
70 | end
71 | function result = contains(list, chr)
72 | import yaml.*;
73 | for i = 1:length(list)
74 | if strcmp(list{i}, chr)
75 | result = true;
76 | return;
77 | end;
78 | end;
79 | result = false;
80 | end
81 |
--------------------------------------------------------------------------------
/source/+yaml/dosubstitution.m:
--------------------------------------------------------------------------------
1 | function result = dosubstitution(r, dictionary)
2 | import yaml.*;
3 | if ~exist('dictionary','var')
4 | dictionary = {};
5 | end;
6 | result = recurse(r, 0, dictionary);
7 | end
8 | function result = recurse(data, level, dictionary)
9 | import yaml.*;
10 | if iscell(data) && ~ismymatrix(data)
11 | result = iter_cell(data, level, dictionary);
12 | elseif isstruct(data)
13 | result = iter_struct(data, level, dictionary);
14 | elseif ischar(data) && isfield(dictionary, data)
15 | result = dictionary.(data);
16 | else
17 | result = data;
18 | end;
19 | end
20 | function result = iter_cell(data, level, dictionary)
21 | import yaml.*;
22 | result = {};
23 | for i = 1:length(data)
24 | result{i} = recurse(data{i}, level + 1, dictionary);
25 | end;
26 | end
27 | function result = iter_struct(data, level, dictionary)
28 | import yaml.*;
29 | result = data;
30 | for i = fields(data)'
31 | fld = char(i);
32 | result.(fld) = recurse(data.(fld), level + 1, dictionary);
33 | end;
34 | end
35 |
--------------------------------------------------------------------------------
/source/+yaml/external/snakeyaml-1.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/+yaml/external/snakeyaml-1.9.jar
--------------------------------------------------------------------------------
/source/+yaml/extras/GetYamlVals.m:
--------------------------------------------------------------------------------
1 | function [vals, timeaxis] = GetYamlVals(yamldata)
2 | % this function converts data formatted in yaml style (cells containing timestamps and values)
3 | % into matlab user friendly matrices.
4 |
5 | % obtain number of samples
6 | n = max(size(yamldata));
7 |
8 | if n
9 | if not(iscell(yamldata{1}))
10 | timeaxis = double(yamldata{1});
11 | vals = cell2mat(yamldata(2:end));
12 | else
13 |
14 | % create output matrices
15 | timeaxis = NaN*ones(n,1);
16 | if n % only if there are some elements of timeaxis
17 | vals = NaN*ones(n,numel(yamldata{1})-1);
18 | end
19 | for i=1:n
20 | timeaxis(i) = double(yamldata{i}{1});
21 | vals(i,:) = cell2mat(yamldata{i}(2:end));
22 | end
23 | end
24 |
25 | end
26 |
27 | end % end of function
28 |
29 |
--------------------------------------------------------------------------------
/source/+yaml/extras/TimeVals2Cell.m:
--------------------------------------------------------------------------------
1 | function s = TimeVals2Cell(time,datavalues,header)
2 | % creates a typical struct with field named by header. Values are cell of
3 | % date and vals.
4 | % synopsis:
5 | % s = TimeVals2Cell(time,datavalues,header)
6 | if ~iscell(header)
7 | header = {header};
8 | end
9 |
10 | for i=1:numel(header)
11 | s.(header{i}) = [num2cell(DateTime(time)) num2cell(datavalues(:,i))];
12 | end
13 | end
--------------------------------------------------------------------------------
/source/+yaml/iscolumnvector.m:
--------------------------------------------------------------------------------
1 | function result = iscolumnvector(obj)
2 | import yaml.*;
3 | result = isvector(obj) && size(obj,2) == 1 && size(obj,1) > 1 && ndims(obj) == 2;
4 | end
5 |
--------------------------------------------------------------------------------
/source/+yaml/ismymatrix.m:
--------------------------------------------------------------------------------
1 | function result = ismymatrix(obj)
2 | import yaml.*;
3 | result = ndims(obj) == 2 && all(size(obj) > 1);
4 | end
5 |
--------------------------------------------------------------------------------
/source/+yaml/isord.m:
--------------------------------------------------------------------------------
1 | function result = isord(obj)
2 | import yaml.*;
3 | result = ~iscell(obj) && any(size(obj) > 1);
4 | end
5 |
--------------------------------------------------------------------------------
/source/+yaml/isrowvector.m:
--------------------------------------------------------------------------------
1 | function result = isrowvector(obj)
2 | import yaml.*;
3 | result = isvector(obj) && size(obj,1) == 1 && size(obj,2) > 1 && ndims(obj) == 2;
4 | end
5 |
--------------------------------------------------------------------------------
/source/+yaml/issingle.m:
--------------------------------------------------------------------------------
1 | function result = issingle(obj)
2 | import yaml.*;
3 | result = all(size(obj) == 1) ;
4 | end
5 |
--------------------------------------------------------------------------------
/source/+yaml/kwd_parent.m:
--------------------------------------------------------------------------------
1 | function result = kwd_parent()
2 | import yaml.*;
3 | result = 'parent';
4 | end
5 |
--------------------------------------------------------------------------------
/source/+yaml/merge_struct.m:
--------------------------------------------------------------------------------
1 | function result = merge_struct(p, s, donotmerge, deep)
2 | import yaml.*;
3 | if ~( isstruct(p) && isstruct(s) )
4 | error('Only structures can be merged.');
5 | end;
6 | if ~exist('donotmerge','var')
7 | donotmerge = {};
8 | end
9 | if ~exist('deep','var')
10 | deep = 0;
11 | elseif strcmp(deep, 'deep')
12 | deep = 1;
13 | end;
14 | result = p;
15 | for i = fields(s)'
16 | fld = char(i);
17 | if any(cellfun(@(x)isequal(x, fld), donotmerge))
18 | continue;
19 | end;
20 | if deep == 1 && isfield(result, fld) && isstruct(result.(fld)) && isstruct(s.(fld))
21 | result.(fld) = merge_struct(result.(fld), s.(fld), donotmerge, deep);
22 | else
23 | result.(fld) = s.(fld);
24 | end;
25 | end;
26 | end
27 |
--------------------------------------------------------------------------------
/source/ESA_CCI/DATA/GEOTHERMAL_Davies2013.m:
--------------------------------------------------------------------------------
1 | classdef GEOTHERMAL_Davies2013 < matlab.mixin.Copyable
2 |
3 | properties
4 | PARENT
5 | CONST
6 | STATVAR
7 | PARA
8 | end
9 |
10 |
11 | methods
12 |
13 | function heat_flux = provide_PARA(heat_flux)
14 | heat_flux.PARA.geothermal_file = [];
15 | heat_flux.PARA.geothermal_path = [];
16 | end
17 |
18 | function heat_flux = provide_STATVAR(heat_flux)
19 |
20 | end
21 |
22 | function heat_flux = provide_CONST(heat_flux)
23 |
24 | end
25 |
26 | function heat_flux = finalize_init(heat_flux)
27 |
28 | end
29 |
30 | function heat_flux = load_data(heat_flux)
31 |
32 | % heat_flux.PARENT.STATVAR.geothermal = heat_flux.PARENT.STATVAR.latitude .* 0+0.05;
33 |
34 | load([heat_flux.PARA.geothermal_path heat_flux.PARA.geothermal_file]);
35 | heat_flux.PARENT.STATVAR.geothermal = interp2(lat_mat, lon_mat, heat_flow_mat, heat_flux.PARENT.STATVAR.latitude, heat_flux.PARENT.STATVAR.longitude)./1000; %map in W/mK
36 | end
37 |
38 |
39 | end
40 | end
41 |
42 |
--------------------------------------------------------------------------------
/source/ESA_CCI/DATA/LANDCOVER.m:
--------------------------------------------------------------------------------
1 | classdef LANDCOVER < matlab.mixin.Copyable
2 |
3 | properties
4 | PARENT
5 | CONST
6 | STATVAR
7 | PARA
8 | end
9 |
10 |
11 | methods
12 |
13 | function lc = provide_PARA(lc)
14 | lc.PARA.landcover_file = [];
15 | lc.PARA.landcover_path = [];
16 | end
17 |
18 | function lc = provide_STATVAR(lc)
19 |
20 | end
21 |
22 | function lc = provide_CONST(lc)
23 |
24 | end
25 |
26 | function lc = finalize_init(lc)
27 |
28 | end
29 |
30 | function lc = load_data(lc)
31 |
32 | lc.PARENT.STATVAR.landcover = [lc.PARENT.STATVAR.latitude .* 0 + 1 repmat(lc.PARENT.STATVAR.latitude .* 0, 1,9)];
33 |
34 | end
35 |
36 |
37 | end
38 | end
39 |
40 |
--------------------------------------------------------------------------------
/source/ESA_CCI/DATA/assign_range.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid ASSIGN_TILE_PROPERTIES class update_one2one
3 | % updates variables that have the same name in the CryoGrid class as
4 | % provided by the DATA_PROVODER class
5 | %
6 | % S. Westermann, Dec 2022
7 | %========================================================================
8 |
9 | classdef assign_range < matlab.mixin.Copyable
10 |
11 | properties
12 | PARA
13 | CONST
14 | PROJ
15 | end
16 |
17 | methods
18 | function update = provide_PARA(update)
19 |
20 | update.PARA.class_name = [];
21 | update.PARA.class_index = [];
22 |
23 | end
24 |
25 | function update = provide_STATVAR(update)
26 |
27 | end
28 |
29 | function update = provide_CONST(update)
30 |
31 | end
32 |
33 | function update = finalize_init(update)
34 |
35 | end
36 |
37 | function update = assign_tile_properties(update, range)
38 | for i=1:size(update.PARA.class_name,1)
39 | update.PROJ.RUN_INFO.PPROVIDER.CLASSES.(update.PARA.class_name{i,1}){update.PARA.class_index(i,1),1}.PARA.range = range;
40 | update.PROJ.RUN_INFO.PPROVIDER.CLASSES.(update.PARA.class_name{i,1}){update.PARA.class_index(i,1),1}.PARA.number_of_realizations = size(range,1);
41 | end
42 | end
43 |
44 | %-------------param file generation-----
45 | function update = param_file_info(update)
46 | update = provide_PARA(update);
47 |
48 | update.PARA.STATVAR = [];
49 | update.PARA.class_category = 'ASSIGN_TILE_PROPERTIES';
50 | update.PARA.default_value = [];
51 |
52 | update.PARA.comment.class_name = {'name of class in which the variable is changed'};
53 | update.PARA.options.class_name.name = 'H_LIST';
54 | update.PARA.options.class_name.entries_x = {'TILE_1D_standard' 'TILE_1D_standard' 'TILE_1D_standard'};
55 |
56 | update.PARA.comment.class_index = {'index of class in which the variable is changed'};
57 | update.PARA.options.class_index.name = 'H_LIST';
58 | update.PARA.options.class_index.entries_x = {'1' '1' '1'};
59 |
60 | update.PARA.comment.variable = {'name of variable which is changed (must be assigned by DATA PROVIDER class)'};
61 | update.PARA.options.variable.name = 'H_LIST';
62 | update.PARA.options.variable.entries_x = {'latitude' 'longitude' 'altitude'};
63 |
64 | end
65 |
66 | end
67 | end
68 |
69 |
--------------------------------------------------------------------------------
/source/ESA_CCI/DATA_ASSIMILATION/OBSERVABLES/OBS_MULTITILE_SCF_1D.m:
--------------------------------------------------------------------------------
1 | classdef OBS_MULTITILE_SCF_1D < matlab.mixin.Copyable
2 |
3 | properties
4 | PARA
5 | CONST
6 | STATVAR
7 | end
8 |
9 | methods
10 |
11 | function obs = provide_PARA(obs)
12 | end
13 |
14 | function obs = provide_CONST(obs)
15 |
16 | end
17 |
18 | function obs = provide_STATVAR(obs)
19 |
20 | end
21 |
22 | function obs = finalize_init(obs, tile)
23 | end
24 |
25 | function result = observable_operator(obs, tile)
26 |
27 | result = double(sum(tile.SUBSURFACE_CLASS.STATVAR.waterIce_snow,1)>1e-5);
28 |
29 | end
30 |
31 | end
32 | end
33 |
34 |
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/GROUND_MULTITILE_ESA_CCI.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/ESA_CCI/GROUND/GROUND_MULTITILE_ESA_CCI.m
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/GROUND_MULTITILE_ESA_CCI_SEB.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/ESA_CCI/GROUND/GROUND_MULTITILE_ESA_CCI_SEB.m
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/compiled/GROUND_MULTITILE_ESA_CCI_compiled.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/ESA_CCI/GROUND/compiled/GROUND_MULTITILE_ESA_CCI_compiled.m
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/compiled/advance_E_compiled.m:
--------------------------------------------------------------------------------
1 |
2 | function energy = advance_E_compiled(energy, d_energy, timestep)
3 |
4 | energy = energy + d_energy .* timestep;
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/compiled/coder_commands.m:
--------------------------------------------------------------------------------
1 | codegen advance_E_compiled -args {zeros(44,2100), zeros(44,2100),0}
2 | codegen compact_windDrift_compiled -args {zeros(4,2100), zeros(4,2100), zeros(4,2100), zeros(4,2100), zeros(1,2100), 0}
3 | codegen dE_dt_compiled -args {zeros(44,2100), zeros(44,2100), zeros(45,2100), zeros(44,2100)}
4 | codegen get_Tground_compiled -args {zeros(44,2100), zeros(41,2100), zeros(41,2100), zeros(41,2100), zeros(41,2100)}
5 | codegen thermCond_compiled -args {zeros(45,2100), zeros(41,2100), zeros(41,2100), zeros(41,2100), zeros(41,2100)}
6 | codegen thermCond_eff_compiled -args {zeros(45,2100), zeros(45,2100)}
7 | codegen thermCond_snow_compiled -args {zeros(4,2100), zeros(4,2100)}
8 |
9 | %not successful
10 | % codegen advance_E_compiled -args {single(zeros(44,2100)), single(zeros(44,2100)),single(0)}
11 | % codegen dE_dt_compiled -args {single(zeros(44,2100)), single(zeros(44,2100)), single(zeros(45,2100)), single(zeros(44,2100))}
12 | % codegen get_Tground_compiled -args {single(zeros(44,2100)), single(zeros(41,2100)), single(zeros(41,2100)), single(zeros(41,2100)), single(zeros(41,2100))}
13 | % codegen thermCond_compiled -args {single(zeros(45,2100)), single(zeros(41,2100)), single(zeros(41,2100)), single(zeros(41,2100)), single(zeros(41,2100))}
14 | % codegen thermCond_eff_compiled -args {single(zeros(45,2100)), single(zeros(45,2100))}
15 |
16 | codegen get_boundary_condition_u_compiled -args {ground.STATVAR.T, tile.FORCING.TEMP.surfT, tile.ENSEMBLE.PARA.ensemble_size, tile.FORCING.TEMP.melt_bare, tile.ENSEMBLE.STATVAR.melt_fraction, tile.FORCING.TEMP.melt_forest, ground.CONST.day_sec, tile.timestep, tile.FORCING.TEMP.snowfall, tile.ENSEMBLE.STATVAR.snowfall_factor, ground.STATVAR.ice_snow, ground.STATVAR.upper_cell, ground.TEMP.d_energy,ground.TEMP.snow_mat1, ground.CONST.L_f, ground.CONST.c_i, ground.STATVAR.layerThick_snow, tile.ENSEMBLE.STATVAR.wind_speed_class}
17 | codegen get_boundary_condition_u_compiled -args {zeros(45,2100), zeros(1,2100), zeros(1,2100), 0,0, zeros(1,2100), zeros(4,2100), zeros(1,2100), zeros(44,2100), zeros(4,2100), 0, 0, zeros(4,2100), zeros(1,2100)}
18 |
19 |
20 | get_boundary_condition_u_compiled(T, surfT, melt, ...
21 | day_sec, timestep, snow_fall, ice_snow, upper_cell, d_energy, snow_mat1, L_f, c_i, layerThick_snow, wind_speed_class)
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/compiled/compact_windDrift_compiled.m:
--------------------------------------------------------------------------------
1 | function dD_dt = compact_windDrift_compiled(T, ice_snow, layerThick_snow, snow_mat1, wind_compaction_timescale, g)
2 |
3 | %(ground.STATVAR.T(2:5,:), ground.STATVAR.ice_snow, ground.STATVAR.layerThick_snow, ground.TEMP.snow_mat1, tile.ENSEMBLE.STATVAR.wind_compaction_timescale, ground.CONST.g)
4 |
5 |
6 |
7 | T = min(0,T);
8 |
9 | eta_0 = 7.62237e6;
10 | a_eta = 0.1;
11 | b_eta = 0.023;
12 | c_eta = 250;
13 |
14 | rho_ice = 920;
15 | rho_max = 350;
16 |
17 | rho = ice_snow ./ max(1e-20, layerThick_snow) .* rho_ice;
18 |
19 | % rho(:,2)
20 |
21 |
22 | stress = g .* rho_ice .* (cumsum(ice_snow - snow_mat1 .* ice_snow./2));
23 |
24 | % stress(:,2)
25 |
26 |
27 | eta = eta_0 .* rho ./ c_eta .* exp(-a_eta .* T + b_eta .* rho);
28 |
29 | % eta(:,2)
30 |
31 | dD_dt = - stress ./max(1e-10,eta) .* layerThick_snow; %compaction
32 |
33 | % dD_dt(:,2)
34 |
35 |
36 | %dD_dt = dD_dt - PROFILE.snow_mat1 .* rho_ice .* PROFILE.D_ice_snow ./ max(1e-8, rho).^2.* (rho_max - min(rho , rho_max)) ./ tau_0 .* S_I;
37 |
38 | dD_dt = dD_dt - snow_mat1 .* rho_ice .* ice_snow ./ max(1e-8, rho).^2.* (rho_max - min(rho, rho_max)) ./ repmat(wind_compaction_timescale .* 24.* 3600, 4,1);
39 |
40 | % dD_dt(:,2)
41 |
42 |
43 | %dD_dt = dD_dt - repmat(double(sum(PROFILE.D_snow,1)>0.05),4,1) .* PROFILE.snow_mat1 .* rho_ice .* PROFILE.D_ice_snow ./ max(1e-8, rho).^2.* (rho_max - min(rho , rho_max)) ./PROFILE.wind_compaction_timescale;
44 |
45 |
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/compiled/dE_dt_compiled.m:
--------------------------------------------------------------------------------
1 |
2 | function d_energy = dE_dt_compiled(d_energy, thermCond_eff, T, layerDistance)
3 |
4 | %downwards flux
5 | d_energy = d_energy - thermCond_eff.*(T(2:end,:) - T(1:end-1,:)) ./ layerDistance;
6 | %upwards flux, lower boundary already added
7 | d_energy(1:end-1,:) = d_energy(1:end-1,:) + thermCond_eff(2:end,:).*(T(3:end,:) - T(2:end-1,:)) ./ layerDistance(2:end,:);
8 |
9 |
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/compiled/get_Tground_compiled.m:
--------------------------------------------------------------------------------
1 |
2 | function T = get_Tground_compiled(energy, c_thawed, c_frozen, E_frozen, T_end_freezing)
3 |
4 | T = double(energy(5:end,:)>=0) .* energy(5:end,:) ./ c_thawed(2:end,:) + ...
5 | double(energy(5:end,:) <= E_frozen(2:end,:)) .* ((energy(5:end,:) - E_frozen(2:end,:)) ./ c_frozen(2:end,:) + T_end_freezing(2:end,:)) + ...
6 | double(energy(5:end,:) < 0 & energy(5:end,:) > E_frozen(2:end,:)) .* energy(5:end,:)./E_frozen(2:end,:) .*(T_end_freezing(2:end,:));
7 |
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/compiled/get_boundary_condition_u_compiled.m:
--------------------------------------------------------------------------------
1 |
2 | function [surf_T, melt, snowfall, T, d_energy, d_new_snow_layerThick, d_new_melt_layerThick] = get_boundary_condition_u_compiled(T, surf_T, melt, ...
3 | day_sec, timestep, snowfall, ice_snow, upper_cell, d_energy, snow_mat1, L_f, c_i, layerThick_snow, wind_speed_class)
4 |
5 |
6 | %in: tile.FORCING.TEMP.surfT, tile.ENSEMBLE.PARA.ensemble_size,
7 | %tile.FORCING.TEMP.melt_bare, tile.ENSEMBLE.STATVAR.melt_fraction,
8 | %tile.FORCING.TEMP.melt_forest, ground.CONST.day_sec, tile.timestep,
9 | %tile.FORCING.TEMP.snowfall, tile.ENSEMBLE.STATVAR.snowfall_factor,
10 | %ground.STATVAR.ice_snow, ground.STATVAR.upper_cell,
11 | %ground.TEMP.d_energy,ground.TEMP.snow_mat1, ground.CONST.L_f,
12 | %ground.CONST.c_i, ground.STATVAR.layerThick_snow, tile.ENSEMBLE.STATVAR.wind_speed_class
13 |
14 | %out: : surf_T, melt, snowfall, T, TEMP: d_energy, d_new_snow_layerThick
15 |
16 | melt = melt ./ 1000 ./ day_sec .* timestep; %in [m], constant timestep
17 |
18 | snowfall = snowfall ./1000 ./ day_sec .* timestep;
19 | melt = min(melt, sum(ice_snow,1)+ snowfall); %limit the melt, so that it doesn't exceed the existing snow
20 | surf_T = double ((snowfall - melt + sum(ice_snow, 1)) <=0 | (surf_T <0)) .* surf_T; %set to zero if there is snow and T is positive
21 |
22 |
23 | for i=1:4 %assign boundary condition T to correct cell and all cells above
24 | T(i, :) = T(i, :) + double(i<=upper_cell) .* (surf_T - T(i, :));
25 | end
26 |
27 |
28 | d_energy(1:4,:) = d_energy(1:4,:) + snow_mat1 .*(repmat(snowfall./timestep .* (-L_f + surf_T .* c_i), 4, 1) - repmat(melt./timestep, 4, 1) .* (-L_f + T(2:5, :) .* c_i));
29 |
30 |
31 | a = 109;
32 | b = 6;
33 | c = 26;
34 | Ts=min(0,surf_T);
35 | new_snow_density = max(50, a + b.*Ts + (c .* wind_speed_class.^0.5));
36 |
37 |
38 | %melt > snowfall: no increase with new snow density (all new snow melts), decrease with existing snow density
39 | %melt < snowfall: no net melt,
40 |
41 | d_new_snow_layerThick = repmat(double(melt < snowfall) .* (snowfall - melt) .* 920 ./ new_snow_density , 4, 1) .* snow_mat1;
42 | d_new_melt_layerThick = repmat(double(melt > snowfall) .* (melt - snowfall), 4, 1) .* snow_mat1 .* layerThick_snow ./ max(1e-10, ice_snow);
43 |
44 |
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/compiled/thermCond_compiled.m:
--------------------------------------------------------------------------------
1 | function thermCond = thermCond_compiled(T, T_end_freezing, k_frozen, k_freezing, k_thawed)
2 |
3 | thermCond = double(T(5:end,:) < T_end_freezing) .* k_frozen + double(T(5:end,:) > 0) .* k_thawed + ...
4 | double(T(5:end,:) >= T_end_freezing & T(5:end,:) <= 0) .* k_freezing;
5 |
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/compiled/thermCond_eff_compiled.m:
--------------------------------------------------------------------------------
1 | function thermCond_eff = thermCond_eff_compiled(thermCond, layerThick)
2 |
3 | thermCond_eff = thermCond(5:end-1,:).*thermCond(6:end,:) .* (layerThick(5:end-1,:)./2 + layerThick(6:end,:)./2) ./ (thermCond(5:end-1,:).*layerThick(6:end,:)./2 + thermCond(6:end,:).*layerThick(5:end-1,:)./2 ); %size N
4 |
--------------------------------------------------------------------------------
/source/ESA_CCI/GROUND/compiled/thermCond_snow_compiled.m:
--------------------------------------------------------------------------------
1 | function thermCond_snow = thermCond_snow_compiled(ice_snow, layerThick_snow)
2 |
3 | snow_density = min(1, ice_snow ./ max(1e-20, layerThick_snow));
4 | thermCond_snow = max(5e-2, 2.3.*snow_density.^1.88);
5 |
--------------------------------------------------------------------------------
/source/ESA_CCI/OUT/OUT_ESA_CCI_FDD_TDD.m:
--------------------------------------------------------------------------------
1 | classdef OUT_ESA_CCI_FDD_TDD < matlab.mixin.Copyable
2 |
3 |
4 | properties
5 | CONST
6 | PARA
7 | STATVAR
8 | TEMP
9 |
10 | end
11 |
12 | methods
13 |
14 |
15 | function out = provide_PARA(out)
16 |
17 | end
18 |
19 | function out = provide_CONST(out)
20 | end
21 |
22 | function out = provide_STATVAR(out)
23 |
24 | end
25 |
26 |
27 | function out = finalize_init(out, tile)
28 |
29 | out.TEMP.FDD=0;
30 | out.TEMP.TDD=0;
31 | out.TEMP.N=0;
32 |
33 |
34 | end
35 |
36 | function out = store_OUT(out, tile)
37 |
38 |
39 | out.TEMP.FDD = out.TEMP.FDD + tile.SUBSURFACE_CLASS.STATVAR.T(5,:).*double(tile.SUBSURFACE_CLASS.STATVAR.T(5,:)<=0);
40 | out.TEMP.TDD = out.TEMP.TDD + tile.SUBSURFACE_CLASS.STATVAR.T(5,:).*double(tile.SUBSURFACE_CLASS.STATVAR.T(5,:)>0);
41 | out.TEMP.N = out.TEMP.N + 1;
42 |
43 | end
44 |
45 |
46 |
47 | end
48 | end
49 |
50 |
--------------------------------------------------------------------------------
/source/ESA_CCI/STRATIGRAPHY/STRAT_layers_confining_stratigraphies.m:
--------------------------------------------------------------------------------
1 |
2 |
3 | classdef STRAT_layers_confining_stratigraphies < matlab.mixin.Copyable
4 |
5 | properties
6 |
7 | PARA
8 | CONST
9 | STATVAR
10 | end
11 |
12 | methods
13 |
14 |
15 | function strat = provide_PARA(strat)
16 |
17 | strat.PARA.ID = [];
18 | strat.PARA.name = [];
19 |
20 | strat.PARA.layers_organic_stratigraphy = [];
21 | strat.PARA.layers_mineral_stratigraphy = [];
22 |
23 | strat.PARA.stratigraphy_fraction = []; %same as subgrid_index
24 | end
25 |
26 | function strat = provide_CONST(strat)
27 |
28 | end
29 |
30 | function strat = provide_STATVAR(strat)
31 |
32 | end
33 |
34 |
35 | function strat = finalize_init(strat, tile)
36 |
37 |
38 | variables = fieldnames(strat.PARA.layers_organic_stratigraphy);
39 | depth1 = strat.PARA.layers_organic_stratigraphy.depth;
40 | depth1 = [depth1; Inf];
41 | depth2 = strat.PARA.layers_mineral_stratigraphy.depth;
42 | depth2 = [depth2; Inf];
43 |
44 | for i=1:size(variables,1)
45 | if ~strcmp(variables{i,1}, 'depth')
46 | store_var1 = tile.GRID.STATVAR.GRID(1:end-1,1) .*0;
47 | store_var2 = store_var1;
48 | for j=1:size(depth1,1)-1
49 | range = tile.GRID.STATVAR.MIDPOINTS > depth1(j,1) & tile.GRID.STATVAR.MIDPOINTS <= depth1(j+1,1);
50 | store_var1(range,1) = strat.PARA.layers_organic_stratigraphy.(variables{i,1})(j,1);
51 | range = tile.GRID.STATVAR.MIDPOINTS > depth2(j,1) & tile.GRID.STATVAR.MIDPOINTS <= depth2(j+1,1);
52 | store_var2(range,1) = strat.PARA.layers_mineral_stratigraphy.(variables{i,1})(j,1);
53 | end
54 |
55 | strat.STATVAR.(variables{i,1}) = store_var1.* strat.PARA.stratigraphy_fraction + store_var2 .* (1-strat.PARA.stratigraphy_fraction);
56 |
57 | end
58 | end
59 |
60 | end
61 |
62 |
63 |
64 |
65 | end
66 |
67 | end
--------------------------------------------------------------------------------
/source/IO/CLUSTERING/CLUSTER_RAW_VARIABLES.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % service class providing data for CLUSTERING classes
3 | % CLUSTER_RAW_VARIABLES provides unchanged raw data
4 | %
5 | % S. Westermann, Dec 2022
6 | %========================================================================
7 |
8 | classdef CLUSTER_RAW_VARIABLES < matlab.mixin.Copyable
9 |
10 | properties
11 | SPATIAL
12 | PARA
13 | CONST
14 | STATVAR
15 | end
16 |
17 | methods
18 | function cluster = provide_PARA(cluster)
19 | cluster.PARA.variables = [];
20 | end
21 |
22 | function cluster = provide_STATVAR(cluster)
23 |
24 | end
25 |
26 | function cluster = provide_CONST(cluster)
27 |
28 | end
29 |
30 | function cluster = finalize_init(cluster)
31 |
32 | end
33 |
34 | function data = provide_data(cluster)
35 | data = [];
36 | for i=1:size(cluster.PARA.variables,1)
37 | data = [data cluster.SPATIAL.STATVAR.(cluster.PARA.variables{i,1})];
38 | end
39 | end
40 |
41 |
42 |
43 | %-------------param file generation-----
44 | function data = param_file_info(data)
45 | data = provide_PARA(data);
46 |
47 | data.PARA.STATVAR = [];
48 | data.PARA.class_category = 'CLUSTERING DATA';
49 | data.PARA.default_value = [];
50 |
51 | data.PARA.comment.variables = {'list of variables to be used for clustering'};
52 | data.PARA.options.variables.name = 'H_LIST';
53 | data.PARA.options.variables.entries_x = {'latitude' 'longitude' 'altitude'};
54 |
55 | end
56 | end
57 | end
58 |
59 |
--------------------------------------------------------------------------------
/source/IO/CLUSTERING/CLUSTER_SLOPE_ASPECT.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % service class providing data for CLUSTERING classes
3 | % CLUSTER_SLOPE_ASPECT synthesizes slope and aspect data to that they can
4 | % be employed in the clustering
5 | %
6 | % S. Westermann, Dec 2022
7 | %========================================================================
8 |
9 | classdef CLUSTER_SLOPE_ASPECT < matlab.mixin.Copyable
10 |
11 | properties
12 | SPATIAL
13 | PARA
14 | CONST
15 | STATVAR
16 | end
17 |
18 | methods
19 | function cluster = provide_PARA(cluster)
20 |
21 | end
22 |
23 | function cluster = provide_STATVAR(cluster)
24 |
25 | end
26 |
27 | function cluster = provide_CONST(cluster)
28 |
29 | end
30 |
31 | function cluster = finalize_init(cluster)
32 |
33 | end
34 |
35 | function data = provide_data(cluster)
36 | data = [-cosd(cluster.SPATIAL.STATVAR.aspect) sind(cluster.SPATIAL.STATVAR.aspect) sind(cluster.SPATIAL.STATVAR.slope_angle)];
37 | end
38 |
39 |
40 | %-------------param file generation-----
41 | function data = param_file_info(data)
42 | data = provide_PARA(data);
43 |
44 | data.PARA.STATVAR = [];
45 | data.PARA.class_category = 'CLUSTERING DATA';
46 | data.PARA.default_value = [];
47 |
48 | end
49 | end
50 | end
51 |
52 |
--------------------------------------------------------------------------------
/source/IO/COORDINATE_SYSTEM/ASSIGN_TILE_PROPERTIES/tag_out_w_run_number.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid ASSIGN_TILE_PROPERTIES class tag_out_w_run_number
3 | % add the run_number as tag to the OUT class
4 | %
5 | % S. Westermann, Dec 2022
6 | %========================================================================
7 |
8 | classdef tag_out_w_run_number < matlab.mixin.Copyable
9 |
10 | properties
11 | PARA
12 | CONST
13 | PROJ
14 | end
15 |
16 | methods
17 | function update = provide_PARA(update)
18 |
19 | update.PARA.class_name = [];
20 | update.PARA.class_index = [];
21 | end
22 |
23 | function update = provide_STATVAR(update)
24 |
25 | end
26 |
27 | function update = provide_CONST(update)
28 |
29 | end
30 |
31 | function update = finalize_init(update)
32 |
33 | end
34 |
35 | function update = assign_tile_properties(update, run_number)
36 | for i=1:size(update.PARA.class_name,1)
37 | update.PROJ.RUN_INFO.PPROVIDER.CLASSES.(update.PARA.class_name{i,1}){update.PARA.class_index(i,1),1}.PARA.tag = num2str(run_number);
38 | end
39 |
40 | end
41 |
42 |
43 | %-------------param file generation-----
44 | function update = param_file_info(update)
45 | update = provide_PARA(update);
46 |
47 | update.PARA.STATVAR = [];
48 | update.PARA.class_category = 'ASSIGN_TILE_PROPERTIES';
49 | update.PARA.default_value = [];
50 |
51 | update.PARA.comment.class_name = {'name of OUT class in which tag is to be added'};
52 | update.PARA.options.class_name.name = 'H_LIST';
53 |
54 | update.PARA.comment.class_index = {'index of OUT class in which tag is to be added'};
55 | update.PARA.options.class_index.name = 'H_LIST';
56 |
57 | end
58 | end
59 | end
60 |
61 |
--------------------------------------------------------------------------------
/source/IO/COORDINATE_SYSTEM/ASSIGN_TILE_PROPERTIES/update_one2one.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid ASSIGN_TILE_PROPERTIES class update_one2one
3 | % updates variables that have the same name in the CryoGrid class as
4 | % provided by the DATA_PROVODER class
5 | %
6 | % S. Westermann, Dec 2022
7 | %========================================================================
8 |
9 | classdef update_one2one < matlab.mixin.Copyable
10 |
11 | properties
12 | PARA
13 | CONST
14 | PROJ
15 | end
16 |
17 | methods
18 | function update = provide_PARA(update)
19 |
20 | update.PARA.target_class_name = [];
21 | update.PARA.target_class_index = [];
22 | update.PARA.variable = [];
23 |
24 | end
25 |
26 | function update = provide_STATVAR(update)
27 |
28 | end
29 |
30 | function update = provide_CONST(update)
31 |
32 | end
33 |
34 | function update = finalize_init(update)
35 |
36 | end
37 |
38 | function update = assign_tile_properties(update, run_number)
39 | for i=1:size(update.PARA.target_class_name,1)
40 | update.PROJ.RUN_INFO.PPROVIDER.CLASSES.(update.PARA.target_class_name{i,1}){update.PARA.target_class_index(i,1),1}.PARA.(update.PARA.variable{i,1}) = ...
41 | update.PROJ.STATVAR.(update.PARA.variable{i,1})(run_number,:);
42 |
43 | end
44 | end
45 |
46 | %-------------param file generation-----
47 | function update = param_file_info(update)
48 | update = provide_PARA(update);
49 |
50 | update.PARA.STATVAR = [];
51 | update.PARA.class_category = 'ASSIGN_TILE_PROPERTIES';
52 | update.PARA.default_value = [];
53 |
54 | update.PARA.comment.target_class_name = {'name of class in which the variable is changed'};
55 | update.PARA.options.target_class_name.name = 'H_LIST';
56 | update.PARA.options.target_class_name.entries_x = {'TILE_1D_standard' 'TILE_1D_standard' 'TILE_1D_standard'};
57 |
58 | update.PARA.comment.target_class_index = {'index of class in which the variable is changed'};
59 | update.PARA.options.target_class_index.name = 'H_LIST';
60 | update.PARA.options.target_class_index.entries_x = {'1' '1' '1'};
61 |
62 | update.PARA.comment.variable = {'name of variable which is changed (must be assigned by DATA PROVIDER class)'};
63 | update.PARA.options.variable.name = 'H_LIST';
64 | update.PARA.options.variable.entries_x = {'latitude' 'longitude' 'altitude'};
65 |
66 | end
67 |
68 | end
69 | end
70 |
71 |
--------------------------------------------------------------------------------
/source/IO/COORDINATE_SYSTEM/MASK/MASK_altitude.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid DATA_MASK class MASK_altitude
3 | % selects the region of interest as the target points in an altitudinal
4 | % range
5 | %
6 | % S. Westermann, Dec 2022
7 | %========================================================================
8 |
9 | classdef MASK_altitude < matlab.mixin.Copyable
10 |
11 |
12 | properties
13 | PARENT
14 | PARA
15 | CONST
16 | STATVAR
17 | end
18 |
19 | methods
20 |
21 | function mask = provide_PARA(mask)
22 | mask.PARA.min_altitude = [];
23 | mask.PARA.max_altitude = [];
24 | end
25 |
26 | function mask = provide_STATVAR(mask)
27 |
28 | end
29 |
30 | function mask = provide_CONST(mask)
31 |
32 | end
33 |
34 | function mask = finalize_init(mask)
35 |
36 | end
37 |
38 |
39 | function mask = apply_mask(mask)
40 |
41 | mask.PARENT.STATVAR.mask = mask.PARENT.STATVAR.mask & mask.PARENT.STATVAR.altitude <= mask.PARA.max_altitude & mask.PARENT.STATVAR.altitude >= mask.PARA.min_altitude;
42 |
43 | end
44 |
45 |
46 |
47 | %-------------param file generation-----
48 | function mask = param_file_info(mask)
49 | mask = provide_PARA(mask);
50 |
51 | mask.PARA.STATVAR = [];
52 | mask.PARA.class_category = 'DATA_MASK';
53 | mask.PARA.default_value = [];
54 | mask.PARA.options = [];
55 |
56 | mask.PARA.comment.min_altitude = {'minimum altitude of target points'};
57 |
58 | mask.PARA.comment.max_altitude = {'maximum altitude of target points'};
59 | end
60 |
61 |
62 | end
63 | end
64 |
65 |
--------------------------------------------------------------------------------
/source/IO/COORDINATE_SYSTEM/MASK/MASK_fixed_pixel_number.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid MASK class MASK_fraction
3 | % splits the target points in a number of sections. This provides an
4 | % additional level of parallelization for very large data sets, which can
5 | % be useful on clusters with defined walltime.
6 | %
7 | % S. Westermann, Dec 2022
8 | %========================================================================
9 |
10 | classdef MASK_fixed_pixel_number < matlab.mixin.Copyable
11 |
12 |
13 | properties
14 | PARENT
15 | PARA
16 | CONST
17 | STATVAR
18 | end
19 |
20 | methods
21 |
22 | function mask = provide_PARA(mask)
23 | mask.PARA.number_of_pixels = [];
24 | end
25 |
26 | function mask = provide_STATVAR(mask)
27 |
28 | end
29 |
30 | function mask = provide_CONST(mask)
31 |
32 | end
33 |
34 | function mask = finalize_init(mask)
35 |
36 | end
37 |
38 |
39 | function mask = apply_mask(mask)
40 |
41 | index = find(mask.PARENT.STATVAR.mask==1);
42 |
43 | number_of_existing = size(index,1);
44 | yes = randperm(number_of_existing, min(mask.PARA.number_of_pixels, number_of_existing));
45 | index = index(yes,1);
46 |
47 | mask.PARENT.STATVAR.mask = mask.PARENT.STATVAR.mask .*0;
48 | mask.PARENT.STATVAR.mask(index) = 1;
49 |
50 | end
51 |
52 |
53 |
54 | %-------------param file generation-----
55 | function mask = param_file_info(mask)
56 | mask = provide_PARA(mask);
57 |
58 | mask.PARA.STATVAR = [];
59 | mask.PARA.class_category = 'MASK';
60 | mask.PARA.default_value = [];
61 | mask.PARA.options = [];
62 |
63 | mask.PARA.comment.section = {'number of currently modeled section [1 ... number_of_sections]'};
64 |
65 | mask.PARA.comment.number_of_sections = {'number of sections in which the data set is split'};
66 | end
67 |
68 | end
69 | end
70 |
71 |
--------------------------------------------------------------------------------
/source/IO/COORDINATE_SYSTEM/MASK/MASK_fraction.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid MASK class MASK_fraction
3 | % splits the target points in a number of sections. This provides an
4 | % additional level of parallelization for very large data sets, which can
5 | % be useful on clusters with defined walltime.
6 | %
7 | % S. Westermann, Dec 2022
8 | %========================================================================
9 |
10 | classdef MASK_fraction < matlab.mixin.Copyable
11 |
12 |
13 | properties
14 | PARENT
15 | PARA
16 | CONST
17 | STATVAR
18 | end
19 |
20 | methods
21 |
22 | function mask = provide_PARA(mask)
23 | mask.PARA.section = [];
24 | mask.PARA.number_of_sections = [];
25 | end
26 |
27 | function mask = provide_STATVAR(mask)
28 |
29 | end
30 |
31 | function mask = provide_CONST(mask)
32 |
33 | end
34 |
35 | function mask = finalize_init(mask)
36 |
37 | end
38 |
39 |
40 | function mask = apply_mask(mask)
41 |
42 | index = find(mask.PARENT.STATVAR.mask==1);
43 |
44 | number_of_existing = size(index,1);
45 | range = round((mask.PARA.section -1) .* number_of_existing./mask.PARA.number_of_sections)+1:round(mask.PARA.section .* number_of_existing./mask.PARA.number_of_sections);
46 | yes = logical(zeros(number_of_existing,1));
47 | yes(range) = 1;
48 | index(~yes) = [];
49 |
50 | mask.PARENT.STATVAR.mask = mask.PARENT.STATVAR.mask .*0;
51 | mask.PARENT.STATVAR.mask(index) = 1;
52 |
53 | end
54 |
55 |
56 |
57 | %-------------param file generation-----
58 | function mask = param_file_info(mask)
59 | mask = provide_PARA(mask);
60 |
61 | mask.PARA.STATVAR = [];
62 | mask.PARA.class_category = 'MASK';
63 | mask.PARA.default_value = [];
64 | mask.PARA.options = [];
65 |
66 | mask.PARA.comment.section = {'number of currently modeled section [1 ... number_of_sections]'};
67 |
68 | mask.PARA.comment.number_of_sections = {'number of sections in which the data set is split'};
69 | end
70 |
71 | end
72 | end
73 |
74 |
--------------------------------------------------------------------------------
/source/IO/COORDINATE_SYSTEM/POINT/POINT_SIMPLE.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid SPATIAL_REFERENCE class POINT_SIMPLE
3 | % POINT class providing a minimum of information (geographic coordinates,
4 | % altitude, area) for a single target point.
5 | % Recommended for simple simulations.
6 | %
7 | % S. Westermann, Dec 2022
8 | %========================================================================
9 |
10 | classdef POINT_SIMPLE < matlab.mixin.Copyable
11 |
12 | properties
13 | RUN_INFO
14 | PARA
15 | CONST
16 | STATVAR
17 | TEMP
18 | ACTION
19 | end
20 |
21 | methods
22 | function point = provide_PARA(point)
23 | point.PARA.latitude = [];
24 | point.PARA.longitude = [];
25 | point.PARA.altitude = [];
26 | point.PARA.area = [];
27 | end
28 |
29 | function point = provide_STATVAR(point)
30 |
31 | end
32 |
33 | function point = provide_CONST(point)
34 |
35 | end
36 |
37 | function point = finalize_init(point)
38 | point.STATVAR.latitude = point.PARA.latitude;
39 | point.STATVAR.longitude = point.PARA.longitude;
40 | point.STATVAR.altitude = point.PARA.altitude;
41 | point.STATVAR.area = point.PARA.area;
42 |
43 | point.STATVAR.slope_angle = 0; %
44 | point.STATVAR.aspect = 0; %
45 | point.STATVAR.skyview_factor = 0; %
46 | point.STATVAR.horizon_angles = 0;
47 | point.STATVAR.horizon_bins = 0;
48 | end
49 |
50 |
51 | %-------------param file generation-----
52 | function point = param_file_info(point)
53 | point = provide_PARA(point);
54 |
55 | point.PARA.STATVAR = [];
56 | point.PARA.class_category = 'SPATIAL_REFERENCE';
57 | point.PARA.options = [];
58 |
59 | point.PARA.comment.latitude = {'latitude in decimal degrees'};
60 | point.PARA.default_value.latitude = {78.9};
61 |
62 | point.PARA.comment.longitude = {'longitude in decimal degrees'};
63 | point.PARA.default_value.longitude = {11.1};
64 |
65 | point.PARA.comment.altitude = {'altitude in m a.s.l.'};
66 | point.PARA.default_value.altitude = {10};
67 |
68 | point.PARA.comment.area = {'area of target point in m2'};
69 | point.PARA.default_value.area = {1};
70 | end
71 |
72 | end
73 | end
74 |
75 |
--------------------------------------------------------------------------------
/source/IO/DATA_ASSIMILATION/OBSERVABLES/OBS_snow_covered_fraction_1D.m:
--------------------------------------------------------------------------------
1 | classdef OBS_snow_covered_fraction_1D < matlab.mixin.Copyable
2 |
3 | properties
4 | PARA
5 | CONST
6 | STATVAR
7 | end
8 |
9 | methods
10 |
11 | function obs = provide_PARA(obs)
12 | end
13 |
14 | function obs = provide_CONST(obs)
15 |
16 | end
17 |
18 | function obs = provide_STATVAR(obs)
19 |
20 | end
21 |
22 | function obs = finalize_init(obs, tile)
23 | end
24 |
25 | function result = observable_operator(obs, tile)
26 | result = 0;
27 | CURRENT = tile.TOP.NEXT;
28 | while ~(strcmp(class(CURRENT), 'Bottom'))
29 | class_name = class(CURRENT);
30 | if strcmp(class_name(1:4), 'SNOW')
31 | result = 1;
32 | break
33 | end
34 | if any(strcmp(properties(CURRENT), 'CHILD'))
35 | if isempty(CURRENT.CHILD) || CURRENT.CHILD == 0
36 | result = 0;
37 | else
38 | result = CURRENT.CHILD.STATVAR.area ./ CURRENT.STATVAR.area(1,1);
39 | end
40 | break
41 | end
42 | CURRENT = CURRENT.NEXT;
43 | end
44 |
45 | end
46 |
47 | end
48 | end
49 |
50 |
--------------------------------------------------------------------------------
/source/IO/FORCING/ENSEMBLE/PERTURB_forcing_simple.m:
--------------------------------------------------------------------------------
1 | classdef PERTURB_forcing_simple < matlab.mixin.Copyable
2 |
3 |
4 | properties
5 | PARA
6 | CONST
7 | STATVAR
8 | end
9 |
10 | methods
11 | function perturb = provide_PARA(perturb)
12 | perturb.PARA.Tair_bias = [];
13 | perturb.PARA.Sin_rel_error = [];
14 | perturb.PARA.snow_fraction = [];
15 | perturb.PARA.rain_fraction = [];
16 | perturb.PARA.all_rain_T = [];
17 | perturb.PARA.all_snow_T = [];
18 | end
19 |
20 | function perturb = provide_CONST(perturb)
21 | perturb.CONST.sigma = [];
22 | end
23 |
24 | function perturb = provide_STATVAR(perturb)
25 |
26 | end
27 |
28 | function perturb = finalize_init(perturb, tile)
29 |
30 | end
31 |
32 | function forcing = perturb_forcing(perturb, forcing)
33 | sky_emissivity = forcing.TEMP.Lin ./ (forcing.TEMP.Tair+273.15).^4 ./ perturb.CONST.sigma;
34 | forcing.TEMP.Tair = forcing.TEMP.Tair + perturb.PARA.Tair_bias;
35 | forcing.TEMP.Lin = sky_emissivity .* perturb.CONST.sigma .* (forcing.TEMP.Tair+273.15).^4;
36 | forcing.TEMP.Sin = forcing.TEMP.Sin .* (1 + perturb.PARA.Sin_rel_error);
37 |
38 | total_precip = forcing.TEMP.rainfall + forcing.TEMP.snowfall;
39 | forcing.TEMP.rainfall = total_precip .* (double(forcing.TEMP.Tair >= perturb.PARA.all_rain_T) + ...
40 | double(forcing.TEMP.Tair > perturb.PARA.all_snow_T & forcing.TEMP.Tair < perturb.PARA.all_rain_T) .* ...
41 | (forcing.TEMP.Tair - perturb.PARA.all_snow_T) ./ max(1e-12, (perturb.PARA.all_rain_T - perturb.PARA.all_snow_T)));
42 | forcing.TEMP.snowfall = total_precip - forcing.TEMP.rainfall;
43 | forcing.TEMP.snowfall = forcing.TEMP.snowfall .* perturb.PARA.snow_fraction;
44 | forcing.TEMP.rainfall = forcing.TEMP.rainfall .* perturb.PARA.rain_fraction;
45 |
46 | end
47 |
48 | end
49 | end
50 |
51 |
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/@FORCING_seb_salt/FORCING_seb_salt.m:
--------------------------------------------------------------------------------
1 | % forcing data
2 |
3 |
4 | classdef FORCING_seb_salt
5 | properties
6 | DATA %all data
7 | TEMP %at each timestep
8 | PARA
9 | STATUS %forcing data suitable for the modules that are to be run -> can be used
10 | end
11 |
12 |
13 | methods
14 |
15 | function forcing = set_parameters(forcing, filename, rain_fraction, snow_fraction, altitude, salt_concentration) %salt_c can be given as parameter, but gets overwritten when time series is available in the focing mat-file
16 | forcing.PARA.filename = filename;
17 | forcing.PARA.rain_fraction = rain_fraction;
18 | forcing.PARA.snow_fraction = snow_fraction;
19 | forcing.PARA.altitude = altitude;
20 | forcing.PARA.saltConcForcing = salt_concentration;
21 | end
22 |
23 | % function forcing = load_forcing_from_mat(forcing);
24 | % function forcing = interpolate_forcing(t, forcing);
25 |
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/@FORCING_seb_salt/interpolate_forcing.m:
--------------------------------------------------------------------------------
1 | function forcing = interpolate_forcing(t, forcing)
2 |
3 |
4 | posit=floor((t-forcing.DATA.timeForcing(1,1))./(forcing.DATA.timeForcing(2,1)-forcing.DATA.timeForcing(1,1)))+1;
5 |
6 |
7 | forcing.TEMP.snowfall=forcing.DATA.snowfall(posit,1)+(forcing.DATA.snowfall(posit+1,1)-forcing.DATA.snowfall(posit,1)).*(t-forcing.DATA.timeForcing(posit,1))./(forcing.DATA.timeForcing(2,1)-forcing.DATA.timeForcing(1,1));
8 |
9 | forcing.TEMP.rainfall=forcing.DATA.rainfall(posit,1)+(forcing.DATA.rainfall(posit+1,1)-forcing.DATA.rainfall(posit,1)).*(t-forcing.DATA.timeForcing(posit,1))./(forcing.DATA.timeForcing(2,1)-forcing.DATA.timeForcing(1,1));
10 |
11 | forcing.TEMP.Lin=forcing.DATA.Lin(posit,1)+(forcing.DATA.Lin(posit+1,1)-forcing.DATA.Lin(posit,1)).*(t-forcing.DATA.timeForcing(posit,1))./(forcing.DATA.timeForcing(2,1)-forcing.DATA.timeForcing(1,1));
12 |
13 | forcing.TEMP.Sin=forcing.DATA.Sin(posit,1)+(forcing.DATA.Sin(posit+1,1)-forcing.DATA.Sin(posit,1)).*(t-forcing.DATA.timeForcing(posit,1))./(forcing.DATA.timeForcing(2,1)-forcing.DATA.timeForcing(1,1));
14 |
15 | forcing.TEMP.Tair=forcing.DATA.Tair(posit,1)+(forcing.DATA.Tair(posit+1,1)-forcing.DATA.Tair(posit,1)).*(t-forcing.DATA.timeForcing(posit,1))./(forcing.DATA.timeForcing(2,1)-forcing.DATA.timeForcing(1,1));
16 |
17 | forcing.TEMP.wind=forcing.DATA.wind(posit,1)+(forcing.DATA.wind(posit+1,1)-forcing.DATA.wind(posit,1)).*(t-forcing.DATA.timeForcing(posit,1))./(forcing.DATA.timeForcing(2,1)-forcing.DATA.timeForcing(1,1));
18 |
19 | forcing.TEMP.q=forcing.DATA.q(posit,1)+(forcing.DATA.q(posit+1,1)-forcing.DATA.q(posit,1)).*(t-forcing.DATA.timeForcing(posit,1))./(forcing.DATA.timeForcing(2,1)-forcing.DATA.timeForcing(1,1));
20 |
21 | forcing.TEMP.p=forcing.DATA.p(posit,1)+(forcing.DATA.p(posit+1,1)-forcing.DATA.p(posit,1)).*(t-forcing.DATA.timeForcing(posit,1))./(forcing.DATA.timeForcing(2,1)-forcing.DATA.timeForcing(1,1));
22 |
23 | forcing.TEMP.saltConcForcing = forcing.PARA.saltConcForcing;
24 |
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/@FORCING_seb_salt/load_forcing_from_mat.m:
--------------------------------------------------------------------------------
1 | function forcing = load_forcing_from_mat(forcing)
2 |
3 | temp=load(['forcing/' forcing.PARA.filename], 'FORCING');
4 |
5 | forcing.DATA.rainfall=temp.FORCING.data.rainfall.*forcing.PARA.rain_fraction;
6 | forcing.DATA.snowfall=temp.FORCING.data.snowfall.*forcing.PARA.snow_fraction;
7 | forcing.DATA.Tair = temp.FORCING.data.Tair;
8 | forcing.DATA.Lin = temp.FORCING.data.Lin;
9 | forcing.DATA.Sin = temp.FORCING.data.Sin;
10 | forcing.DATA.q = temp.FORCING.data.q;
11 | forcing.DATA.wind = temp.FORCING.data.wind;
12 | forcing.DATA.timeForcing = temp.FORCING.data.t_span;
13 |
14 |
15 | if std(forcing.DATA.timeForcing(2:end,1)-forcing.DATA.timeForcing(1:end-1,1))~=0
16 | disp('timestamp of forcing data is not in regular intervals -> check, fix and restart')
17 | forcing.STATUS=0;
18 | return
19 | else
20 | forcing.STATUS=1;
21 | end
22 |
23 | %here, consistency checks, RH->q calculation, set threhsolds for wind, etc. could be placed
24 |
25 | forcing.DATA.wind(forcing.DATA.wind<0.5)=0.5; %set min wind speed to 0.5 m/sec to avoid breakdown of turbulence
26 | forcing.DATA.Lin(find(forcing.DATA.Lin==0)) = 5.67e-8 .* (forcing.DATA.Tair(find(forcing.DATA.Lin==0))+273.15).^4;
27 |
28 | %set pressure to mean pressure at corresponding altitude (international
29 | %altitude formula) if not provided by the forcing time series
30 | if ~isfield(temp.FORCING.data, 'p')
31 | forcing.DATA.p=forcing.DATA.Tair.*0 + 1013.25.*100.*(1-0.0065./288.15.*forcing.PARA.altitude).^5.255;
32 | else
33 | forcing.DATA.p = temp.FORCING.data.p;
34 | end
35 |
36 | if ~isfield(temp.FORCING.data, 'saltConcForcing') %allows seeting the upper boundary of salt_c as a parameter
37 | forcing.DATA.saltConcForcing=forcing.DATA.Tair.*0 + forcing.PARA.saltConcForcing;
38 | else
39 | forcing.DATA.saltConcForcing = temp.FORCING.data.saltConcForcing;
40 | end
41 |
42 |
43 | %initialize TEMP
44 | forcing.TEMP.snowfall=0;
45 | forcing.TEMP.rainfall=0;
46 | forcing.TEMP.Lin=0;
47 | forcing.TEMP.Sin=0;
48 | forcing.TEMP.Tair=0;
49 | forcing.TEMP.wind=0;
50 | forcing.TEMP.RH=0;
51 | forcing.TEMP.q=0;
52 | forcing.TEMP.p=0;
53 | forcing.TEMP.saltConcForcing=0;
54 |
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/FORCING_Tair_Tlb_fixed.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/FORCING/FORCING_discontinued/FORCING_Tair_Tlb_fixed.m
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/FORCING_do_nothing.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/FORCING/FORCING_discontinued/FORCING_do_nothing.m
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/FORCING_read_out.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid FORCING class FORCING_seb
3 |
4 | % S. Westermann, November 2020
5 | %========================================================================
6 |
7 | classdef FORCING_read_out < matlab.mixin.Copyable
8 |
9 | properties
10 | forcing_index
11 | DATA % forcing data time series
12 | TEMP % forcing data interpolated to a timestep
13 | PARA % parameters
14 | STATUS
15 | end
16 |
17 |
18 | methods
19 |
20 |
21 |
22 |
23 | function forcing = provide_PARA(forcing)
24 |
25 | %forcing.PARA.filename = [];
26 | forcing.PARA.start_time = []; % start time of the simulations (must be within the range of data in forcing file)
27 | forcing.PARA.end_time = []; % end time of the simulations (must be within the range of data in forcing file)
28 | forcing.PARA.heatFlux_lb = []; % heat flux at the lower boundary [W/m2] - positive values correspond to energy gain
29 | forcing.PARA.airT_height = []; % height above ground at which air temperature (and wind speed!) from the forcing data are applied.
30 | end
31 |
32 | function forcing = provide_CONST(forcing)
33 |
34 | end
35 |
36 | function forcing = provide_STATVAR(forcing)
37 |
38 | end
39 |
40 | function forcing = finalize_init(forcing, tile)
41 |
42 | forcing.PARA.start_time = datenum(forcing.PARA.start_time, 'dd.mm.yyyy');
43 |
44 | forcing.PARA.end_time = datenum(forcing.PARA.end_time, 'dd.mm.yyyy');
45 | end
46 |
47 |
48 | function forcing = interpolate_forcing(forcing, tile)
49 |
50 | end
51 |
52 | end
53 | end
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/FORCING_seb.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/FORCING/FORCING_discontinued/FORCING_seb.m
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/FORCING_seb_loop.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/FORCING/FORCING_discontinued/FORCING_seb_loop.m
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/FORCING_slope_forest_seb_readNc.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/FORCING/FORCING_discontinued/FORCING_slope_forest_seb_readNc.m
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/FORCING_slope_forest_seb_readNc2.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/FORCING/FORCING_discontinued/FORCING_slope_forest_seb_readNc2.m
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/FORCING_slope_seb.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/FORCING/FORCING_discontinued/FORCING_slope_seb.m
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/FORCING_slope_seb_readNc.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/FORCING/FORCING_discontinued/FORCING_slope_seb_readNc.m
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/FORCING_tair_precip.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/FORCING/FORCING_discontinued/FORCING_tair_precip.m
--------------------------------------------------------------------------------
/source/IO/FORCING/FORCING_discontinued/FORCING_ubT.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/FORCING/FORCING_discontinued/FORCING_ubT.m
--------------------------------------------------------------------------------
/source/IO/FORCING/TIER1/READ_FORCING_base.m:
--------------------------------------------------------------------------------
1 | classdef READ_FORCING_base < matlab.mixin.Copyable
2 |
3 | properties
4 |
5 | end
6 |
7 | methods
8 |
9 | end
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/source/IO/FORCING/TIER1/READ_FORCING_mat.m:
--------------------------------------------------------------------------------
1 | classdef READ_FORCING_mat < READ_FORCING_base
2 |
3 | properties
4 |
5 | end
6 |
7 | methods
8 | function [data, timestamp] = read_mat(forcing, full_file, variables) %, start_date, end_date)
9 |
10 | temp = load(full_file, 'FORCING');
11 | temp=temp.FORCING.data;
12 | % Implement some cropping of data if start_date and end_date
13 | % are passed
14 |
15 | for i=1:size(variables,1)
16 | if isfield(temp, variables{i,1})
17 | data.(variables{i,1}) = squeeze(temp.(variables{i,1}));
18 | end
19 | end
20 | if isfield(temp, 't_span')
21 | timestamp = temp.t_span;
22 | elseif isfield(temp, 'timeForcing')
23 | timestamp = temp.timeForcing;
24 | else
25 | timestamp = 0;
26 | disp('no suitable timestamp');
27 | end
28 | end
29 |
30 | % %for TopoScale
31 | function data = read_mat_ERA4D(forcing, full_file)
32 | data = load(full_file, 'era');
33 | data = data.era;
34 | end
35 |
36 |
37 | end
38 |
39 | end
40 |
--------------------------------------------------------------------------------
/source/IO/INIT_STEADY_STATE/INIT_TTOP_from_out.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INIT_STEADY_STATE class INIT_TTOP_from_out
3 | % CryoGrid INIT_STEADY_STATE class used in conjcntion with the TILE_BUILDER
4 | % class new_init_steady_state; reads the temperature on the top of
5 | % permafrost (TTOP) and the maximum depth of the permafrost table from an
6 | % existing OUT file written by the class OUT_TDD_FDD.
7 | % It is used in the accelerated spin-up procedure.
8 |
9 | % S. Westermann, Jan 2022
10 | %========================================================================
11 |
12 |
13 | classdef INIT_TTOP_from_out < matlab.mixin.Copyable
14 |
15 |
16 | properties
17 | PARA
18 | CONST
19 | STATVAR
20 | end
21 |
22 |
23 | methods
24 |
25 |
26 | function init = provide_PARA(init)
27 |
28 | init.PARA.out_folder = []; %if empty, use the result folder
29 | init.PARA.out_file = [];
30 |
31 | end
32 |
33 | function init = provide_CONST(init)
34 |
35 | end
36 |
37 | function init = provide_STATVAR(init)
38 |
39 | end
40 |
41 | function init = finalize_init(init, tile)
42 | if isempty(init.PARA.out_folder) || sum(isnan(init.PARA.out_folder))>0
43 | init.PARA.out_folder = [tile.PARA.result_path tile.PARA.run_name '/'];
44 | init.PARA.out_file = [tile.PARA.run_name '_OUT_FDD_TDD.mat'];
45 | end
46 | temp=load([init.PARA.out_folder init.PARA.out_file], 'out');
47 | out = temp.out;
48 | tile.PARA.T_first_cell = out.STATVAR.TTOP;
49 | tile.PARA.start_depth_steady_state = out.STATVAR.TTOP_depth;
50 | end
51 |
52 |
53 |
54 | %-------------param file generation-----
55 | function init = param_file_info(init)
56 | init = provide_PARA(init);
57 |
58 | init.PARA.STATVAR = [];
59 | init.PARA.options = [];
60 | init.PARA.class_category = 'init_steady_state';
61 |
62 | init.PARA.default_value.out_file = {''};
63 | init.PARA.comment.out_file = {'if empty, use the default file name generated by OUT_FDD_TDD'};
64 |
65 | init.PARA.default_value.out_folder = {''};
66 | init.PARA.comment.out_folder = {'if empty, use the result folder'};
67 |
68 | end
69 |
70 |
71 | end
72 | end
--------------------------------------------------------------------------------
/source/IO/OUT/OUT_all_lateral_CG3style.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/OUT/OUT_all_lateral_CG3style.m
--------------------------------------------------------------------------------
/source/IO/OUT/OUT_all_lateral_averages.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/IO/OUT/OUT_all_lateral_averages.m
--------------------------------------------------------------------------------
/source/IO/OUT/OUT_do_nothing.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid OUT class OUT_do_nothing
3 | % does not store any output, generally used during model spin-up
4 | % S. Westermann, Jan 2021
5 | %========================================================================
6 |
7 |
8 | classdef OUT_do_nothing < matlab.mixin.Copyable
9 |
10 |
11 | properties
12 | out_index
13 | STRATIGRAPHY
14 | LATERAL
15 | TIMESTAMP
16 | MISC
17 | TEMP
18 | PARA
19 | OUTPUT_TIME
20 | SAVE_TIME
21 | CONST
22 |
23 | end
24 |
25 |
26 | methods
27 |
28 |
29 | function out = provide_PARA(out)
30 | out.PARA.display_timestep = [];
31 | end
32 |
33 | function out = provide_CONST(out)
34 |
35 | end
36 |
37 | function out = provide_STATVAR(out)
38 |
39 | end
40 |
41 |
42 |
43 | function out = finalize_init(out, tile)
44 |
45 | if ~isempty(out.PARA.display_timestep)
46 | out.OUTPUT_TIME = tile.FORCING.PARA.start_time + out.PARA.display_timestep;
47 | else
48 | out.OUTPUT_TIME = tile.FORCING.PARA.end_time +1; %set to time that is never reached
49 | end
50 | end
51 |
52 | %---------------time integration-------------
53 |
54 |
55 | function out = store_OUT(out, tile)
56 | if tile.t==out.OUTPUT_TIME
57 | disp([datestr(tile.t)])
58 | out.OUTPUT_TIME = out.OUTPUT_TIME + out.PARA.display_timestep;
59 | end
60 |
61 | end
62 |
63 | %-------------param file generation-----
64 | function out = param_file_info(out)
65 | out = provide_PARA(out);
66 |
67 | out.PARA.STATVAR = [];
68 | out.PARA.options = [];
69 | out.PARA.class_category = 'OUT';
70 |
71 | out.PARA.default_value.display_timestep = {5};
72 | out.PARA.comment.display_timestep = {'timestep that model progress is displayed [days]'};
73 |
74 | end
75 |
76 | % function xls_out = write_excel(out)
77 | % XLS_OUT Is a cell array corresponding to the class-specific content of the parameter excel file (refer to function write_controlsheet).
78 | %
79 | % xls_out = {'OUT','index',NaN,NaN;'OUT_all',1,NaN,NaN;'output_timestep',0.250000000000000,'[days]',NaN;'save_date','01.09.','provide in format dd.mm.',NaN;'save_interval',1,'[y]','if left empty, the entire output will be written out at the end';'OUT_END',NaN,NaN,NaN};
80 | % end
81 |
82 |
83 |
84 | end
85 | end
--------------------------------------------------------------------------------
/source/IO/PROVIDER/BASE_PROVIDER.m:
--------------------------------------------------------------------------------
1 | classdef BASE_PROVIDER
2 |
3 | properties
4 | PARA
5 | CONST
6 | CLASSES %struct of all classes
7 | STORAGE
8 | RUN_INFO_CLASS %RUN_INFO class to start
9 | end
10 |
11 | methods
12 |
13 | function [run_info, provider] = run_model(provider)
14 | provider = check_PARA_CONST(provider);
15 | run_info = copy(provider.RUN_INFO_CLASS);
16 | run_info.PPROVIDER = provider;
17 | run_info = finalize_init(run_info);
18 | end
19 |
20 | %check if all PARA and CONST are assigned; generic function used,
21 | %which can be overwritten in individual classes, like
22 | %TILE_1D_standard, if PARA itself depends on input PARA
23 | function provider = check_PARA_CONST(provider)
24 | class_names = fieldnames(provider.CLASSES);
25 | for i=1:size(class_names,1)
26 | for j=1:size(provider.CLASSES.(class_names{i,1}),1)
27 | check_if_PARA_assigned(provider.CLASSES.(class_names{i,1}){j,1});
28 | check_if_CONST_assigned(provider.CLASSES.(class_names{i,1}){j,1});
29 | end
30 | end
31 | end
32 |
33 | end
34 | end
35 |
36 |
--------------------------------------------------------------------------------
/source/IO/PROVIDER/PROVIDER_EXCEL3D.m:
--------------------------------------------------------------------------------
1 | classdef PROVIDER_EXCEL3D < PROVIDER_EXCEL
2 |
3 |
4 | methods
5 |
6 |
7 | function provider = assign_paths_excel3d(provider, run_name, result_path, constant_file)
8 | provider = assign_paths_excel(provider, run_name, result_path, constant_file);
9 | end
10 |
11 |
12 | function provider = read_const_excel3d(provider)
13 | provider = read_const_excel(provider);
14 | end
15 |
16 | function provider = read_parameters_excel3d(provider)
17 | provider = read_parameters_excel(provider);
18 | end
19 |
20 | %parallel runs
21 | function provider = update_parameter_file_excel3d(provider, param_file_number)
22 | %change parameter file
23 | parameter_file = [provider.PARA.result_path provider.PARA.run_name '/' provider.PARA.run_name '_' num2str(param_file_number) '.xlsx'];
24 | provider.PARA.parameter_file = parameter_file;
25 | end
26 |
27 | function provider = update_run_name_excel3d(provider, worker_number)
28 | %change run name and make new result directories if necessary
29 | provider.PARA.run_name = [provider.PARA.run_name '_' num2str(worker_number)];
30 | if ~(exist([provider.PARA.result_path provider.PARA.run_name ])==7)
31 | mkdir([provider.PARA.result_path provider.PARA.run_name]);
32 | end
33 | end
34 |
35 |
36 | end
37 | end
38 |
39 |
--------------------------------------------------------------------------------
/source/IO/PROVIDER/PROVIDER_EXCEL_edu.m:
--------------------------------------------------------------------------------
1 | classdef PROVIDER_EXCEL_edu < PROVIDER_EXCEL
2 |
3 |
4 | methods
5 |
6 | function provider = assign_paths_excel_edu(provider, run_name, result_path, constant_file)
7 |
8 | constant_file = [result_path run_name '/' constant_file '.xlsx'];
9 | parameter_file = [result_path run_name '/' run_name '.xlsx'];
10 | parameter_file_edu = [result_path run_name '/' run_name '_edu.xlsx'];
11 |
12 | provider.PARA.run_name = run_name;
13 | provider.PARA.result_path = result_path;
14 | provider.PARA.parameter_file = parameter_file;
15 | provider.PARA.parameter_file_edu = parameter_file_edu;
16 | provider.PARA.constant_file = constant_file;
17 | %provider.PARA.forcing_path = forcing_path;
18 | end
19 |
20 |
21 | function provider = read_const_excel_edu(provider)
22 | provider = read_const_excel(provider);
23 | end
24 |
25 | function provider = read_parameters_excel_edu(provider)
26 | provider = read_parameters_excel(provider);
27 | %read adn overwrite
28 | data = read_excel2cell(provider, provider.PARA.parameter_file_edu);
29 | disp(provider.PARA.parameter_file_edu)
30 | for i=1:size(data,1)
31 | class_name = data{i,1};
32 | class_index = data{i,2};
33 | PARA_name = data{i,3};
34 | PARA_value = data{i,4};
35 |
36 | try
37 | % if isnumeric(PARA_value)
38 | % provider.CLASSES.(class_name){class_index,1}.(PARA_name) = PARA_value;
39 | % new_class.PARA.(fieldnames_PARA{ii,1}) = cell2mat(data(j+1:k-1,2));
40 | % else
41 | % new_class.PARA.(fieldnames_PARA{ii,1}) = data(j+1:k-1,2);
42 | % end
43 | provider.CLASSES.(class_name){class_index,1}.PARA.(PARA_name) = PARA_value;
44 | end
45 | end
46 | end
47 |
48 |
49 | end
50 | end
51 |
52 |
--------------------------------------------------------------------------------
/source/IO/PROVIDER/PROVIDER_MAT.m:
--------------------------------------------------------------------------------
1 | classdef PROVIDER_MAT < BASE_PROVIDER
2 |
3 |
4 | methods
5 |
6 | function provider = assign_paths_mat(provider, run_name, result_path)
7 |
8 |
9 | parameter_file = [result_path run_name '/' run_name '.mat'];
10 | provider.PARA.run_name = run_name;
11 | provider.PARA.result_path = result_path;
12 | provider.PARA.parameter_file = parameter_file;
13 |
14 | provider_from_file = load(provider.PARA.parameter_file);
15 |
16 | fn = fieldnames(provider_from_file);
17 | provider_from_file = provider_from_file.(fn{1,1});
18 |
19 | fn = fieldnames(provider_from_file);
20 |
21 | for i=1:size(fn,1)
22 | if any(strcmp(properties(provider), fn{i,1}))
23 | fn2 = fieldnames(provider_from_file.(fn{i,1}));
24 | for j=1:size(fn2,1)
25 | provider.(fn{i,1}).(fn2{j,1}) = provider_from_file.(fn{i,1}).(fn2{j,1});
26 | end
27 | end
28 | end
29 |
30 | end
31 | end
32 | end
33 |
34 |
--------------------------------------------------------------------------------
/source/IO/PROVIDER/PROVIDER_YAML3D.m:
--------------------------------------------------------------------------------
1 | classdef PROVIDER_YAML3D < PROVIDER_YAML
2 |
3 |
4 | methods
5 |
6 |
7 | function provider = assign_paths_yaml3d(provider, run_name, result_path, constant_file)
8 | provider = assign_paths_yaml(provider, run_name, result_path, constant_file);
9 | end
10 |
11 |
12 | function provider = read_const_yaml3d(provider)
13 | provider = read_const_yaml(provider);
14 | end
15 |
16 | function provider = read_parameters_yaml3d(provider)
17 | provider = read_parameters_yaml(provider);
18 | end
19 |
20 | %parallel runs
21 | function provider = update_parameter_file_yaml3d(provider, param_file_number)
22 | %change parameter file
23 | provider = update_parameter_file_yaml(provider, param_file_number);
24 | end
25 |
26 | function provider = update_run_name_yaml3d(provider, worker_number)
27 | %change run name and make new result directories if necessary
28 | provider = update_run_name_yaml(provider, worker_number);
29 | end
30 |
31 |
32 |
33 | end
34 | end
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/source/IO/PROVIDER/check_if_CONST_assigned.m:
--------------------------------------------------------------------------------
1 | function check_if_CONST_assigned(CG_class)
2 |
3 | if ~isempty(CG_class.CONST)
4 | parameters = fieldnames(CG_class.CONST);
5 | for i=1:size(parameters,1)
6 | if size(CG_class.CONST.(parameters{i,1}),1) == 0 && size(CG_class.CONST.(parameters{i,1}),2) == 0
7 | disp(['Warning: CONST ' parameters{i,1} ' in class ' class(CG_class) ' not assigned'])
8 | end
9 | end
10 |
11 | end
--------------------------------------------------------------------------------
/source/IO/PROVIDER/check_if_PARA_assigned.m:
--------------------------------------------------------------------------------
1 | function check_if_PARA_assigned(CG_class)
2 |
3 | if ~isempty(CG_class.PARA)
4 | parameters = fieldnames(CG_class.PARA);
5 | for i=1:size(parameters,1)
6 | if size(CG_class.PARA.(parameters{i,1}),1) == 0 && size(CG_class.PARA.(parameters{i,1}),2) == 0
7 | disp(['Warning: PARA ' parameters{i,1} ' in class ' class(CG_class) ' not assigned'])
8 | end
9 | end
10 | end
--------------------------------------------------------------------------------
/source/IO/STRATIGRAPHY_STATVAR/STRAT_linear2.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid STRATIGRAPHY_STATVAR class STRAT_linear
3 | % STRAT_linear defines the initial stratigraphy of model
4 | % state variables by linearly interpolating between values at depths
5 | % provided. Depths must be given as depth below the ground surface, and the
6 | % final depth value must extend below the depth of the model domain.
7 | % S. Westermann, T. Ingeman-Nielsen, J. Scheer, October 2020
8 | %========================================================================
9 |
10 | classdef STRAT_linear2 < matlab.mixin.Copyable
11 |
12 | properties
13 | strat_linear_index
14 | STATVAR
15 | PARA
16 | CONST
17 | depth
18 | variable_names
19 | variable_values
20 | variable_gridded
21 | end
22 |
23 | methods
24 |
25 |
26 | function stratigraphy = provide_PARA(stratigraphy)
27 | stratigraphy.PARA.points = [];
28 | end
29 |
30 | function stratigraphy = provide_CONST(stratigraphy)
31 |
32 | end
33 |
34 | function stratigraphy = provide_STATVAR(stratigraphy)
35 |
36 | end
37 |
38 |
39 | function stratigraphy = finalize_init(stratigraphy, tile)
40 |
41 | variables = fieldnames(stratigraphy.PARA.points);
42 | depth = stratigraphy.PARA.points.depth;
43 | for i=1:size(variables,1)
44 | if ~strcmp(variables{i,1}, 'depth')
45 | stratigraphy.STATVAR.(variables{i,1}) = interp1(depth, stratigraphy.PARA.points.(variables{i,1}), tile.GRID.STATVAR.MIDPOINTS, 'linear');
46 | end
47 | end
48 | end
49 |
50 |
51 |
52 | %-------------param file generation-----
53 | function stratigraphy = param_file_info(stratigraphy)
54 | stratigraphy = provide_PARA(stratigraphy);
55 | %default
56 | stratigraphy.PARA.default_value = [];
57 | stratigraphy.PARA.STATVAR = [];
58 | stratigraphy.PARA.comment = [];
59 | stratigraphy.PARA.class_category = 'STRATIGRAPHY_STATVAR';
60 | stratigraphy.PARA.options.points.name = 'STRAT_MATRIX';
61 | stratigraphy.PARA.options.points.entries_y = {0; 10; 5000};
62 | stratigraphy.PARA.options.points.is_statvar_matrix = 1; %fill with STATVAR that are identified for initialization in GROUND classes
63 | end
64 |
65 | end
66 |
67 | end
--------------------------------------------------------------------------------
/source/IO/TILE_BUILDER/new_init.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid TLE_BUILDER class new_init
3 | % CryoGrid TLE_BUILDER class which accomplishes the initialization of the
4 | % TILE class based only on user-defined profiles of mode state avraibles.
5 | % Note that the code (i.e. what the TILE_BUILDER class actually does in in
6 | % the respective TILE classes which the TILE_BUILDER class is compatible
7 | % with
8 | % S. Westermann, Jan 2021
9 | %========================================================================
10 |
11 |
12 | classdef new_init
13 |
14 | properties
15 | TILE
16 | end
17 |
18 | methods
19 | function build_tile(builder)
20 | builder.TILE = build_tile_new_init(builder.TILE);
21 | end
22 |
23 | % function builder = provide_PARA(builder)
24 | %
25 | % builder.PARA.latitude = [];
26 | % builder.PARA.longitude = [];
27 | % builder.PARA.altitude = [];
28 | % builder.PARA.domain_depth = [];
29 | % builder.PARA.area = [];
30 | %
31 | % builder.PARA.forcing_class = [];
32 | % builder.PARA.forcing_class_index = [];
33 | % builder.PARA.grid_class = [];
34 | % builder.PARA.grid_class_index = [];
35 | % builder.PARA.out_class = [];
36 | % builder.PARA.out_class_index = [];
37 | % builder.PARA.strat_classes_class = [];
38 | % builder.PARA.strat_classes_class_index = [];
39 | % builder.PARA.strat_statvar_class = [];
40 | % builder.PARA.strat_statvar_class_index = [];
41 | % builder.PARA.lateral_class = [];
42 | % builder.PARA.lateral_class_index = [];
43 | % builder.PARA.lateral_IA_classes = [];
44 | % builder.PARA.lateral_IA_classes_index = [];
45 | % end
46 | end
47 | end
48 |
49 |
--------------------------------------------------------------------------------
/source/IO/TILE_BUILDER/new_init_steady_state.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid TILE_BUILDER class new_init_steady_state
3 | % CryoGrid TLE_BUILDER class used to initialize the TILE class with a
4 | % steady-state temperature profile computed from the geothermal heat flux
5 | % and a give temperature at a defined depth, as well as profiles of soil
6 | % properties provieded by the user. The temperature/depth can either be
7 | % provided by the user, or calculated by an INIT_STEADY_STATE class, e.g.
8 | % using the model forcing or the output of a previous simulation.
9 | % Note that the code (i.e. what the TILE_BUILDER class actually does in in
10 | % the respective TILE classes which the TILE_BUILDER class is compatible
11 | % with
12 | % S. Westermann, Aug 2021
13 | %========================================================================
14 |
15 | classdef new_init_steady_state
16 |
17 | properties
18 | TILE
19 | end
20 |
21 | methods
22 | function build_tile(builder)
23 | builder.TILE = build_tile_new_init_steady_state(builder.TILE);
24 | end
25 |
26 | end
27 | end
28 |
29 |
--------------------------------------------------------------------------------
/source/IO/TILE_BUILDER/new_init_with_TTOP.m:
--------------------------------------------------------------------------------
1 | classdef new_init_with_TTOP
2 |
3 | properties
4 | TILE
5 | end
6 |
7 | methods
8 | function build_tile(builder)
9 | builder.TILE = build_tile_new_init_TTOP_GlobPermafrost(builder.TILE);
10 | end
11 |
12 | end
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/source/IO/TILE_BUILDER/restart_OUT_last_timestep.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid TILE_BUILDER class restart_OUT_last_timestep
3 | % CryoGrid TLE_BUILDER class used to initialize the TILE class with a
4 | % CryoGrid stratigraphy written by the OUT class OUT_last_timestep. In
5 | % order to change the model FORCING or OUT classes, use in sequential
6 | % simulation of TILE classes and use TILE_BUILDER update_forcing_out for
7 | % the following TILE class.
8 | % Note that the code (i.e. what the TILE_BUILDER class actually does in in
9 | % the respective TILE classes which the TILE_BUILDER class is compatible
10 | % with
11 | % S. Westermann, Jan 2021
12 | %========================================================================
13 |
14 |
15 | classdef restart_OUT_last_timestep
16 |
17 | properties
18 | TILE
19 | end
20 |
21 | methods
22 | function build_tile(builder)
23 | builder.TILE = build_tile_restart_OUT_last_timestep(builder.TILE);
24 | end
25 | % function builder = provide_PARA(builder)
26 | % builder.PARA.restart_file_path = [];
27 | % builder.PARA.restart_file_name = [];
28 | % end
29 | end
30 | end
31 |
32 |
--------------------------------------------------------------------------------
/source/IO/TILE_BUILDER/restart_from_OUT_update_classes.m:
--------------------------------------------------------------------------------
1 | classdef restart_from_OUT_update_classes
2 |
3 | properties
4 | TILE
5 | end
6 |
7 | methods
8 |
9 | function build_tile(builder)
10 | builder.TILE = build_tile_restart_OUT_update_classes(builder.TILE);
11 | end
12 |
13 | end
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/source/IO/TILE_BUILDER/update_forcing_out.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid TLE_BUILDER class update_forcing_out
3 | % CryoGrid TLE_BUILDER class to be used in the context of sequential
4 | % simulations of several TILE classes after each other. Reads the final
5 | % state of the previous TILE class for initialization of the CryoGrid
6 | % stratigraphy, but overwrites FORCING and OUT classes with user-rpovided
7 | % ones.
8 | % Note that the code (i.e. what the TILE_BUILDER class actually does in in
9 | % the respective TILE classes which the TILE_BUILDER class is compatible
10 | % with
11 | % S. Westermann, Jan 2021
12 | %========================================================================
13 |
14 | classdef update_forcing_out
15 |
16 |
17 | properties
18 | TILE
19 | end
20 |
21 | methods
22 | function build_tile(builder)
23 | builder.TILE = build_tile_update_forcing_out(builder.TILE);
24 | end
25 | %
26 | % function builder = provide_PARA(builder)
27 | %
28 | % builder.PARA.forcing_class = [];
29 | % builder.PARA.forcing_class_index = [];
30 | %
31 | % builder.PARA.out_class = [];
32 | % builder.PARA.out_class_index = [];
33 | %
34 | % end
35 | end
36 | end
37 |
38 |
--------------------------------------------------------------------------------
/source/IO/TILE_BUILDER/update_forcing_out_with_TTOP.m:
--------------------------------------------------------------------------------
1 | classdef update_forcing_out_with_TTOP
2 |
3 |
4 | properties
5 | TILE
6 | end
7 |
8 | methods
9 | function build_tile(builder)
10 | builder.TILE = build_tile_update_forcing_out_TTOP(builder.TILE);
11 | end
12 | end
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/source/LATERAL/BASE/BASE_LATERAL.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid BASE class for all LATERAL classes
3 | % contains variables and initialization routines
4 | % S. Westermann, T. Ingeman-Nielsen, J. Scheer, Oct 2020
5 | %========================================================================
6 |
7 |
8 | classdef BASE_LATERAL < matlab.mixin.Copyable
9 |
10 | properties
11 | class_index
12 | CONST %constants
13 | PARA %external service parameters, all other
14 | STATVAR %energy, water content, etc.
15 | TEMP %derivatives in prognostic timestep and optimal timestep
16 | PARENT
17 | end
18 |
19 | methods
20 | %-------------param file generation-----
21 | function ground = param_file_info(ground)
22 | ground = provide_PARA(ground);
23 |
24 | ground.PARA.class_category = 'LATERAL_IA';
25 | ground.PARA.STATVAR = [];
26 | ground.PARA.default_value = [];
27 | ground.PARA.comment = [];
28 | ground.PARA.options = [];
29 | end
30 |
31 | end
32 | end
33 |
34 |
--------------------------------------------------------------------------------
/source/LATERAL/LAT1D/LAT_REMOVE_SUBSURFACE_WATER.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid LATERAL_IA class which removes all subsurface water for GROUND classses with water bucket scheme,
3 | % all water exceeding the field capacity is removed
4 | % S. Westermann, Oct 2020
5 | %========================================================================
6 |
7 | classdef LAT_REMOVE_SUBSURFACE_WATER < BASE_LATERAL
8 |
9 |
10 | methods
11 |
12 |
13 | %----mandatory functions---------------
14 | %----initialization--------------------
15 |
16 |
17 | function lateral = provide_CONST(lateral)
18 |
19 | end
20 |
21 | function lateral = provide_PARA(lateral)
22 |
23 | end
24 |
25 | function lateral = provide_STATVAR(lateral)
26 | lateral.STATVAR.subsurface_run_off = [];
27 | end
28 |
29 | function lateral = finalize_init(lateral, tile)
30 | lateral.STATVAR.subsurface_run_off = 0;
31 | end
32 |
33 | %----time integration-----
34 |
35 | %only push function required
36 | function lateral = push(lateral, tile)
37 |
38 | CURRENT = lateral.PARENT.TOP.NEXT;
39 | while ~(strcmp(class(CURRENT), 'Bottom'))
40 | CURRENT = lateral_push_remove_subsurfaceWater(CURRENT, lateral);
41 | CURRENT = compute_diagnostic(CURRENT, tile);
42 | CURRENT = CURRENT.NEXT;
43 | end
44 |
45 | end
46 |
47 | function lateral = get_derivatives(lateral, tile)
48 |
49 | end
50 |
51 | function lateral = pull(lateral, tile)
52 |
53 | end
54 |
55 | function lateral = set_ACTIVE(lateral, i, t)
56 | lateral.PARENT.ACTIVE(i,1) = 1;
57 | end
58 | end
59 |
60 | end
61 |
62 |
63 |
--------------------------------------------------------------------------------
/source/LATERAL/LAT1D/LAT_REMOVE_SURFACE_WATER.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid LATERAL_IA class LAT_REMOVE_SURFACE_WATER
3 | % LAT_REMOVE_SURFACE_WATER which removes all surface water overtopping
4 | % the first grid cell for GROUND classses
5 | % This can for example prevent the triggering of a LAKE in some GROUND
6 | % classes, or to analyze the water balance.
7 | % S. Westermann, Oct 2020
8 | %========================================================================
9 |
10 | classdef LAT_REMOVE_SURFACE_WATER < BASE_LATERAL
11 |
12 | methods
13 |
14 | %----mandatory functions---------------
15 | %----initialization--------------------
16 |
17 |
18 | function lateral = provide_CONST(lateral)
19 |
20 | end
21 |
22 | function lateral = provide_PARA(lateral)
23 |
24 | end
25 |
26 | function lateral = provide_STATVAR(lateral)
27 | lateral.STATVAR.surface_run_off = [];
28 | end
29 |
30 |
31 | function lateral = finalize_init(lateral, tile)
32 | lateral.STATVAR.surface_run_off = 0;
33 | end
34 |
35 | %------time integration-------------
36 |
37 | %only push function needed
38 | function lateral = push(lateral, tile)
39 | %remove water from first class in stratigraphy only
40 | TOP.NEXT = lateral_push_remove_surfaceWater(lateral.PARENT.TOP.NEXT, lateral);
41 | end
42 |
43 | function lateral = set_ACTIVE(lateral, i, t)
44 | lateral.PARENT.ACTIVE(i,1) = 1;
45 | end
46 |
47 | function lateral = get_derivatives(lateral, tile)
48 |
49 | end
50 |
51 | function lateral = pull(lateral, tile)
52 |
53 | end
54 |
55 | end
56 | end
57 |
58 |
--------------------------------------------------------------------------------
/source/LATERAL/LAT3D/LAT3D_WATER_UNCONFINED_AQUIFER_RICHARDS_EQ.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/LATERAL/LAT3D/LAT3D_WATER_UNCONFINED_AQUIFER_RICHARDS_EQ.m
--------------------------------------------------------------------------------
/source/TIER_0_base/Bottom.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid Bottom class
3 | % bottom confining class of stratigraphy
4 | % S. Westermann, Oct 2020
5 | %========================================================================
6 |
7 | classdef Bottom < matlab.mixin.Copyable
8 |
9 | properties
10 | PREVIOUS
11 | end
12 |
13 | methods
14 | function obj = init_bottom(obj, bottom_class)
15 | obj.PREVIOUS = bottom_class;
16 | end
17 |
18 | end
19 | end
20 |
21 |
--------------------------------------------------------------------------------
/source/TIER_0_base/IA_BASE.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid base class for all INTERACTION (IA) classes
3 | % S. Westermann, Oct 2020
4 | %========================================================================
5 |
6 | classdef IA_BASE < matlab.mixin.Copyable
7 |
8 | properties
9 | PREVIOUS
10 | NEXT
11 | end
12 |
13 | methods
14 | function finalize_init(IA_BASE, tile)
15 | %do nothing
16 | end
17 | end
18 | end
--------------------------------------------------------------------------------
/source/TIER_0_base/Top.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid TOP class
3 | % top confining class of stratigraphy, storage for sleeping GROUND classes, pointer to lateral class
4 | % S. Westermann, Oct 2020
5 | %========================================================================
6 |
7 | classdef Top < matlab.mixin.Copyable
8 |
9 | properties
10 | NEXT
11 | IA_NEXT
12 | STORE
13 | LATERAL
14 | % FORCING
15 | % TIME
16 | % RUN_NUMBER
17 | % RESULT_PATH
18 | end
19 |
20 | methods
21 | function obj = init_top(obj, top_class)
22 | obj.NEXT = top_class;
23 | end
24 |
25 | end
26 | end
27 |
28 |
--------------------------------------------------------------------------------
/source/TIER_1_processes/HEAT_FLUXES_LATERAL.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid TIER1 library class for functions for lateral fluxes of heat
3 | % contains push and pull functions used in lateral heat flux classes, e.g. LAT3D_HEAT
4 | % S. Westermann, October 2020
5 | %========================================================================
6 |
7 |
8 | classdef HEAT_FLUXES_LATERAL < BASE
9 |
10 |
11 | methods
12 |
13 | function ground = lateral_push_heat_simple(ground, lateral)
14 | depths = ground.STATVAR.upperPos - cumsum([0; ground.STATVAR.layerThick]);
15 | depths = (depths(1:end-1,1) + depths(2:end,1))./2;
16 |
17 | cross_section = lateral.PARA.heatReservoir_contact_length .* ground.STATVAR.layerThick .* double(depths >= lateral.PARA.lowerElevation & depths <= lateral.PARA.upperElevation);
18 |
19 | flux = ground.STATVAR.thermCond .* (lateral.PARA.reservoir_T - ground.STATVAR.T)./ lateral.PARA.distance_heatReservoir .* cross_section;
20 | flux = flux .* lateral.PARENT.IA_TIME_INCREMENT .* lateral.CONST.day_sec;
21 |
22 | ground.STATVAR.energy = ground.STATVAR.energy + flux;
23 | end
24 |
25 | %read information from GROUND class and send it to the LATERAL class
26 | function ground = lateral3D_pull_heat_simple(ground, lateral)
27 | if isempty(lateral.PARENT.STATVAR.depths_heat)
28 | depths = ground.STATVAR.upperPos - cumsum([0; ground.STATVAR.layerThick]);
29 | else
30 | depths = ground.STATVAR.upperPos - cumsum(ground.STATVAR.layerThick);
31 | end
32 | lateral.PARENT.STATVAR.depths_heat = [lateral.PARENT.STATVAR.depths_heat; depths];
33 | lateral.PARENT.STATVAR.thermCond = [lateral.PARENT.STATVAR.thermCond; ground.STATVAR.thermCond];
34 | lateral.PARENT.STATVAR.T_heat = [lateral.PARENT.STATVAR.T_heat; ground.STATVAR.T];
35 | end
36 |
37 | % add lateral heat flux to STATVAR energy
38 | function ground = lateral3D_push_heat_simple(ground, lateral)
39 | ground.STATVAR.energy = ground.STATVAR.energy + lateral.PARENT.STATVAR.heat_flux(1:size(ground.STATVAR.energy,1),1);
40 | lateral.PARENT.STATVAR.heat_flux(1:size(ground.STATVAR.energy,1),:) = [];
41 | end
42 |
43 | end
44 | end
45 |
46 |
--------------------------------------------------------------------------------
/source/TIER_1_processes/INTERACTION/IA_BGC.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for biogeochemistry BGC classes with
3 | % physical GROUND classes
4 | % S. Westermann, November 2021
5 | %========================================================================
6 |
7 | classdef IA_BGC < IA_BASE
8 |
9 | properties
10 |
11 | end
12 |
13 | methods
14 |
15 | %service functions for BGC IA classes
16 |
17 | function overlap = get_overlap_cells(ia_BGC, cell_1, cell_2)
18 |
19 | overlap = [];
20 |
21 | if size(cell_1,1) > 1 && size(cell_2,1) > 1
22 | for i1=1:size(cell_1,1)-1
23 | i2=1;
24 | a = max(0, - max(cell_1(i1,1), cell_2(i2,1)) + min(cell_1(i1+1,1), cell_2(i2+1,1)));
25 |
26 | while a <= 0 && i2 < size(cell_2,1)-1
27 | %overlap2(i1,i2) = a;
28 | i2 = i2+1;
29 | a = max(0, - max(cell_1(i1,1), cell_2(i2,1)) + min(cell_1(i1+1,1), cell_2(i2+1,1)));
30 | end
31 | if a>0
32 | overlap = [overlap; [i1 i2 a ./ ia_BGC.BGC.STATVAR.layerThick(i1,1) a ./ ia_BGC.GROUND.STATVAR.layerThick(i2,1)]];
33 | end
34 |
35 | i2_start = i2;
36 | while a > 0 && i2 < size(cell_2,1)-1
37 |
38 | i2 = i2+1;
39 | a = max(0, - max(cell_1(i1,1), cell_2(i2,1)) + min(cell_1(i1+1,1), cell_2(i2+1,1)));
40 | if a>0
41 | overlap = [overlap; [i1 i2 a ./ ia_BGC.BGC.STATVAR.layerThick(i1,1) a ./ ia_BGC.GROUND.STATVAR.layerThick(i2,1)]];
42 | end
43 | end
44 | i2 = i2_start;
45 | end
46 | end
47 | end
48 |
49 |
50 | end
51 | end
--------------------------------------------------------------------------------
/source/TIER_1_processes/INTERACTION/IA_SALT.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid TIER1 INTERACTION (IA) class for functions related to salt
3 | % diffusion
4 | % NOTE: at this pooint, only zero flux boundary conditions are implemented
5 | % S. Westermann, October 2020
6 | %========================================================================
7 |
8 | classdef IA_SALT < IA_BASE
9 |
10 | methods
11 |
12 | function get_boundary_condition_ZEROFLUX_SALT_NEXT_m(ia_heat_water) %coupling between classes without (PREVIOUS) and with (NEXT) salt balance
13 | ia_heat_water.NEXT.TEMP.F_ub_salt = 0;
14 | ia_heat_water.NEXT.TEMP.d_salt(1) = ia_heat_water.NEXT.TEMP.d_salt(1) + 0;
15 | end
16 |
17 | function get_boundary_condition_ZEROFLUX_SALT_PREVIOUS_m(ia_heat_water) %coupling between classes with (PREVIOUS) and without (NEXT) salt balance
18 | ia_heat_water.PREVIOUS.TEMP.F_lb_salt = 0;
19 | ia_heat_water.PREVIOUS.TEMP.d_salt(end) = ia_heat_water.PREVIOUS.TEMP.d_salt(end) + 0;
20 | end
21 |
22 | end
23 | end
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/source/TIER_1_processes/INTERACTION/IA_VEGETATION_CLM5.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for interaction between a vegetaion class
3 | % and an belowlying soil class. Only for subsurface - canopy interactions,
4 | % such as transpiration, no surface energy/water balance.
5 | % R. B. Zwegiel, February 2022
6 | %========================================================================
7 |
8 | classdef IA_VEGETATION_CLM5 < IA_WATER
9 |
10 | properties
11 | end
12 |
13 | methods
14 |
15 | function ia_soil = distribute_roots_CLM5(ia_soil, tile)
16 | % Vertical root distribution as in 2.11.1.1 in CLM5 documentation
17 | % beta = ia_soil.PREVIOUS.PARA.beta_root; % Root distribution parameter
18 | % dz = ia_soil.NEXT.STATVAR.layerThick;
19 | % z = cumsum(dz);
20 | %
21 | % % Root fraction per soil layer
22 | % f_root = beta.^([0; z(1:end-1)].*100) - beta.^(z*100); % Eq. 11.1
23 | %
24 | % ia_soil.NEXT.STATVAR.f_root = f_root;
25 |
26 | rootzone = double(cumsum(ia_soil.NEXT.STATVAR.layerThick) <=0.5);
27 | f_root = rootzone.* ia_soil.NEXT.STATVAR.layerThick ./ sum(ia_soil.NEXT.STATVAR.layerThick.* rootzone);
28 | ia_soil.NEXT.STATVAR.f_root = f_root;
29 |
30 | end
31 |
32 | function beta = get_soil_moisture_stress(ia_soil, tile)
33 | % as described by Sinclair (2005), and Verhoef & Egea (2014)
34 | psi = ia_soil.NEXT.STATVAR.waterPotential;
35 | f_root = ia_soil.NEXT.STATVAR.f_root;
36 | psi_wilt = ia_soil.PREVIOUS.PARA.psi_wilt;
37 |
38 | beta = sum(f_root.*max(0,1-psi./psi_wilt) .* double(ia_soil.NEXT.STATVAR.T>=0));
39 | end
40 |
41 | function ia_soil = get_water_transpiration(ia_soil)
42 | ia_soil = get_water_transpiration@IA_WATER(ia_soil);
43 | end
44 |
45 | end
46 | end
--------------------------------------------------------------------------------
/source/TIER_1_processes/INTERACTION/get_water_transpiration.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_1_processes/INTERACTION/get_water_transpiration.m
--------------------------------------------------------------------------------
/source/TIER_1_processes/LB_TEMPERATURE_FORCING.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid TIER1 library class for functions related heat conduction
3 | % using only an upper boundary temperature forcing.
4 | %
5 | % T. Ingeman-Nielsen, S. Westermann, December 2021
6 | %========================================================================
7 |
8 | classdef LB_TEMPERATURE_FORCING < BASE
9 |
10 | methods
11 | %------boundary conditions-----
12 | function ground = get_boundary_condition_l(ground, forcing)
13 | % Calculate upper boundary flux and energy change due to
14 | % temperature forcing.
15 | ground.TEMP.F_lb = -(ground.STATVAR.T(end,end)-forcing.TEMP.T_lb).*ground.STATVAR.thermCond(end,end)./(ground.STATVAR.layerThick(end,end)/2);
16 | ground.TEMP.d_energy(end,end) = ground.TEMP.d_energy(end,end) + ground.TEMP.F_lb.*ground.STATVAR.area(end,end);
17 | end
18 |
19 | end
20 | end
21 |
22 |
--------------------------------------------------------------------------------
/source/TIER_1_processes/SNOW_MELTFACTOR.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_1_processes/SNOW_MELTFACTOR.m
--------------------------------------------------------------------------------
/source/TIER_1_processes/UB_TEMPERATURE_FORCING.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid TIER1 library class for functions related heat conduction
3 | % using only an upper boundary temperature forcing.
4 | %
5 | % T. Ingeman-Nielsen, S. Westermann, December 2021
6 | %========================================================================
7 |
8 | classdef UB_TEMPERATURE_FORCING < BASE
9 |
10 | methods
11 | %------boundary conditions-----
12 | function ground = get_boundary_condition_u(ground, forcing)
13 | % Calculate upper boundary flux and energy change due to
14 | % temperature forcing.
15 | ground.TEMP.F_ub = -(forcing.TEMP.Tair - ground.STATVAR.T(1,1)).*ground.STATVAR.thermCond(1,1)./(ground.STATVAR.layerThick(1,1)/2);
16 | ground.TEMP.d_energy(1,1) = ground.TEMP.d_energy(1,1) - ground.TEMP.F_ub.*ground.STATVAR.area(1,1);
17 | end
18 |
19 | function ground = get_ub_temperature(ground, forcing)
20 | % Calculate upper boundary flux and energy change due to
21 | % temperature forcing.
22 | ground.TEMP.F_ub = -(forcing.TEMP.Tair - ground.STATVAR.T(1,1)).*ground.STATVAR.thermCond(1,1)./(ground.STATVAR.layerThick(1,1)/2);
23 | ground.TEMP.d_energy(1,1) = ground.TEMP.d_energy(1,1) - ground.TEMP.F_ub.*ground.STATVAR.area(1,1);
24 | end
25 |
26 | end
27 | end
28 |
29 |
--------------------------------------------------------------------------------
/source/TIER_1_processes/canopy_resistances_CLM5_Stewart.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_1_processes/canopy_resistances_CLM5_Stewart.m
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/BGC/IA_DO_NOTHING.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction between two GROUND
3 | % classes without water cycle
4 | % contains function for SNOW CHILD phase
5 | % S. Westermann, October 2020
6 | %========================================================================
7 |
8 | classdef IA_DO_NOTHING < IA_BASE
9 |
10 | methods
11 |
12 | function get_boundary_condition_m(ia_heat, tile)
13 |
14 | end
15 |
16 |
17 | end
18 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/BGC/trash/anpp_whyme.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_2_full_classes/BGC/trash/anpp_whyme.mat
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction between two GROUND
3 | % classes without water cycle
4 | % contains function for SNOW CHILD phase
5 | % S. Westermann, October 2020
6 | %========================================================================
7 |
8 | classdef IA_HEAT11 < IA_HEAT
9 |
10 | methods
11 |
12 | function get_boundary_condition_m(ia_heat, tile)
13 | get_boundary_condition_HEAT_m(ia_heat);
14 | end
15 |
16 | %SNOW
17 | function get_IA_CHILD_boundary_condition_u(ia_heat, tile)
18 | get_boundary_condition_HEAT_IA_CHILD(ia_heat);
19 | end
20 |
21 | end
22 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_LAKE.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction between a LAKE and a
3 | % normal GROUND class
4 | % S. Westermann, October 2020
5 | %========================================================================
6 |
7 | classdef IA_HEAT11_LAKE < IA_HEAT
8 |
9 | methods
10 |
11 | function get_boundary_condition_m(ia_heat, tile)
12 | get_boundary_condition_HEAT_LAKE_m(ia_heat);
13 | end
14 |
15 | end
16 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_SALT01.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction between two GROUND
3 | % classes and zero salt flux boundary conditions for below class
4 | % S. Westermann, October 2020
5 | %========================================================================
6 |
7 | classdef IA_HEAT11_SALT01 < IA_HEAT & IA_SALT
8 |
9 | methods
10 |
11 | function get_boundary_condition_m(ia_heat, tile)
12 | get_boundary_condition_HEAT_m(ia_heat)
13 | get_boundary_condition_ZEROFLUX_SALT_NEXT_m(ia_heat)
14 | end
15 |
16 | end
17 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_SALT10.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction between two GROUND
3 | % classes and zero salt flux boundary conditions for GROUND class above
4 | % S. Westermann, October 2020
5 | %========================================================================
6 |
7 | classdef IA_HEAT11_SALT10 < IA_HEAT & IA_SALT
8 |
9 | methods
10 |
11 | function get_boundary_condition_m(ia_heat, tile)
12 | get_boundary_condition_HEAT_m(ia_heat);
13 | get_boundary_condition_ZEROFLUX_SALT_PREVIOUS_m(ia_heat);
14 | end
15 |
16 | end
17 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER01.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction between two GROUND
3 | % classes and zero water flux boundary conditions for above class
4 | % S. Westermann, October 2020
5 | %========================================================================
6 |
7 | classdef IA_HEAT11_WATER01 < IA_WATER & IA_HEAT
8 |
9 | methods
10 |
11 | function get_boundary_condition_m(ia_heat_water, tile)
12 | get_boundary_condition_HEAT_m(ia_heat_water);
13 | get_boundary_condition_ZEROFLUX_NEXT_m(ia_heat_water);
14 | end
15 |
16 | %SNOW
17 | function get_IA_CHILD_boundary_condition_u(ia_heat_water, tile)
18 | get_boundary_condition_HEAT_IA_CHILD(ia_heat_water);
19 | get_boundary_condition_ZEROFLUX_NEXT_m(ia_heat_water);
20 | end
21 |
22 | end
23 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER10.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction between two GROUND
3 | % classes and zero water flux boundary conditions for class below
4 | % includes function for SNOW CHILD phase
5 | % S. Westermann, October 2020
6 | %========================================================================
7 |
8 | classdef IA_HEAT11_WATER10 < IA_WATER & IA_HEAT
9 |
10 | methods
11 |
12 | function get_boundary_condition_m(ia_heat_water, tile)
13 | get_boundary_condition_HEAT_m(ia_heat_water);
14 | get_boundary_condition_ZEROFLUX_PREVIOUS_m(ia_heat_water);
15 | end
16 |
17 | %if upper class is SNOW CHILD
18 | function get_IA_CHILD_boundary_condition_u(ia_heat_water, tile)
19 | get_boundary_condition_HEAT_IA_CHILD(ia_heat_water);
20 | get_boundary_condition_ZEROFLUX_PREVIOUS_m(ia_heat_water);
21 | end
22 |
23 |
24 | end
25 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER10_LAKE.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction between a LAKE class
3 | % and a GROUND class without water cycle
4 | % S. Westermann, October 2020
5 | %========================================================================
6 |
7 | classdef IA_HEAT11_WATER10_LAKE < IA_HEAT & IA_WATER
8 |
9 | methods
10 |
11 | function get_boundary_condition_m(ia_heat_water, tile)
12 | get_boundary_condition_HEAT_LAKE_m(ia_heat_water);
13 | get_boundary_condition_ZEROFLUX_PREVIOUS_m(ia_heat_water);
14 | end
15 |
16 | %---inherited TIER 1 functions-------
17 |
18 | function get_boundary_condition_HEAT_LAKE_m(ia_heat_water)
19 | get_boundary_condition_HEAT_LAKE_m@IA_HEAT(ia_heat_water);
20 | end
21 |
22 | function get_boundary_condition_ZEROFLUX_PREVIOUS_m(ia_heat_water)
23 | get_boundary_condition_ZEROFLUX_PREVIOUS_m@IA_WATER(ia_heat_water);
24 | end
25 |
26 | end
27 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER11.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction and water fluxes between a two GROUND classes with bucket water
3 | % S. Westermann, October 2020
4 | %========================================================================
5 |
6 | classdef IA_HEAT11_WATER11 < IA_WATER & IA_HEAT
7 |
8 | methods
9 |
10 | function get_boundary_condition_m(ia_heat_water, tile)
11 | get_boundary_condition_HEAT_m(ia_heat_water);
12 | get_boundary_condition_BUCKET_m(ia_heat_water);
13 | ia_heat_water.NEXT.TEMP.surface_runoff = 0;
14 | end
15 |
16 | end
17 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER11_LAKE.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction and water fluxes between a LAKE class
3 | % and a GROUND class with bucket water
4 | % S. Westermann, October 2020
5 | %========================================================================
6 |
7 | classdef IA_HEAT11_WATER11_LAKE < IA_WATER & IA_HEAT
8 |
9 | methods
10 |
11 | function get_boundary_condition_m(ia_heat_water, tile)
12 | get_boundary_condition_HEAT_LAKE_m(ia_heat_water);
13 | get_boundary_condition_BUCKET_LAKE_m(ia_heat_water);
14 | end
15 |
16 | end
17 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER11_LAKE_LAKE_discontinued.m:
--------------------------------------------------------------------------------
1 | classdef IA_HEAT11_WATER11_LAKE_LAKE < IA_WATER & IA_HEAT
2 |
3 | methods
4 |
5 | function get_boundary_condition_m(ia_heat_water)
6 | get_boundary_condition_HEAT_m(ia_heat_water);
7 | get_boundary_condition_BUCKET_LAKE_LAKE_m(ia_heat_water);
8 | end
9 |
10 |
11 |
12 | function trigger_remove_LAKE(ia_heat_water, forcing)
13 | lake1 = ia_heat_water.PREVIOUS;
14 | lake2 = ia_heat_water.NEXT;
15 |
16 | lake2.STATVAR.waterIce(1) = lake2.STATVAR.XwaterIce(1) + sum(lake1.STATVAR.waterIce,1);
17 | lake2.STATVAR.energy(1) = lake2.STATVAR.energy(1) + sum(lake1.STATVAR.energy,1);
18 | lake2.STATVAR.layerThick(1) = lake2.STATVAR.layerThick(1) + sum(lake1.STATVAR.waterIce ./ lake1.STATVAR.area ,1);
19 | if sum(strcmp('CHILD', fieldnames(lake1)))
20 | if lake2.CHILD ~= 0
21 | lake2.CHILD = lake1.CHILD;
22 | lake2.CHILD.PARENT = lake2;
23 | lake2.CHILD.NEXT = lake2;
24 | lake2.IA_CHILD = get_IA_class(class(lake2.CHILD), class(lake2));
25 | lake2.IA_CHILD.PREVIOUS = lake2.CHILD;
26 | lake2.IA_CHILD.NEXT = lake2; %SNOW CHILD created
27 | end
28 | end
29 |
30 | lake2.PREVIOUS = lake1.PREVIOUS;
31 | lake2.PREVIOUS.NEXT = lake2;
32 | if ~strcmp(class(lake2.PREVIOUS), 'Top')
33 | lake2.IA_PREVIOUS = get_IA_class(class(lake2), class(lake2.PREVIOUS));
34 | lake2.PREVIOUS.IA_NEXT = lake2.IA_PREVIOUS;
35 | lake2.IA_PREVIOUS.PREVIOUS = lake2.PREVIOUS;
36 | lake2.IA_PREVIOUS.NEXT = lake2;
37 | end
38 | lake2 = compute_diagnostic(lake2,forcing);
39 | end
40 |
41 |
42 |
43 | end
44 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER11_LAKE_SNOW_discontinued.m:
--------------------------------------------------------------------------------
1 | classdef IA_HEAT11_WATER11_LAKE_SNOW < IA_WATER & IA_HEAT
2 | %lake on top of snow - not completed!!
3 |
4 | methods
5 |
6 | function get_boundary_condition_m(ia_heat_water)
7 | get_boundary_condition_HEAT_m(ia_heat_water);
8 |
9 | get_boundary_condition_BUCKET_LAKE_SNOW_m(ia_heat_water);
10 | end
11 |
12 |
13 |
14 | function trigger_create_LAKE(ia_heat_water, ground, forcing)
15 |
16 | end
17 |
18 |
19 |
20 | function trigger_remove_LAKE(ia_heat_water, forcing)
21 | lake = ia_heat_water.PREVIOUS;
22 | snow = ia_heat_water.NEXT;
23 |
24 | snow.STATVAR.waterIce(1) = snow.STATVAR.waterIce(1) + sum(lake.STATVAR.waterIce,1);
25 | snow.STATVAR.energy(1) = snow.STATVAR.energy(1) + sum(lake.STATVAR.energy,1);
26 | snow.STATVAR.layerThick(1) = snow.STATVAR.layerThick(1) + sum(lake.STATVAR.waterIce ./ lake.STATVAR.area ,1);
27 | if sum(strcmp('CHILD', fieldnames(lake))) %unusual case, lake gets removed when it has a snow child - not sure this works
28 | if lake.CHILD ~= 0
29 | snow.STATVAR.waterIce(1) = snow.STATVAR.waterIce(1) + lake.CHILD.STATVAR.waterIce;
30 | snow.STATVAR.energy(1) = snow.STATVAR.energy(1) + lake.CHILD.STATVAR.energy;
31 | snow.STATVAR.layerThick(1) = snow.STATVAR.layerThick(1) + lake.CHILD.STATVAR.waterIce ./ lake.CHILD.STATVAR.area;
32 | end
33 | end
34 |
35 | snow.PREVIOUS = lake.PREVIOUS;
36 | snow.PREVIOUS.NEXT = snow;
37 | if ~strcmp(class(snow.PREVIOUS), 'Top')
38 | snow.IA_PREVIOUS = get_IA_class(class(snow), class(snow.PREVIOUS));
39 | snow.PREVIOUS.IA_NEXT = snow.IA_PREVIOUS;
40 | snow.IA_PREVIOUS.PREVIOUS = snow.PREVIOUS;
41 | snow.IA_PREVIOUS.NEXT = snow;
42 | end
43 | snow = compute_diagnostic(snow,forcing);
44 | end
45 |
46 | end
47 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER11_RichardsEq_LAKE.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction and water fluxes between a LAKE class
3 | % and a GROUND class with Richards equation water
4 | % S. Westermann, October 2020
5 | %========================================================================
6 |
7 | classdef IA_HEAT11_WATER11_RichardsEq_LAKE < IA_WATER & IA_HEAT
8 |
9 | methods
10 |
11 | function get_boundary_condition_m(ia_heat_water, tile)
12 | get_boundary_condition_HEAT_LAKE_m(ia_heat_water);
13 | %get_boundary_condition_BUCKET_LAKE_m(ia_heat_water);
14 | get_boundary_condition_RichardsEq_LAKE_m(ia_heat_water);
15 | end
16 |
17 | end
18 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER11_RichardsEq_LAKE_XICE.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction and water fluxes between a LAKE class
3 | % and a GROUND class with Richards equation water and excess ice
4 | % S. Westermann, October 2020
5 | %========================================================================
6 |
7 | classdef IA_HEAT11_WATER11_RichardsEq_LAKE_XICE < IA_HEAT11_WATER11_LAKE_XICE
8 |
9 | methods
10 |
11 | function get_boundary_condition_m(ia_heat_water, tile)
12 | get_boundary_condition_HEAT_LAKE_m(ia_heat_water);
13 | get_boundary_condition_RichardsEq_Xice_LAKE_m(ia_heat_water);
14 | end
15 |
16 | %trigger functions handled in IA_HEAT11_WATER11_LAKE_XICE
17 |
18 | end
19 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER11_RichardsEq_SNOW.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction and water fluxes between a SNOW class
3 | % and a GROUND class with Richards equation water
4 | % contains function for SNOW CHILD phase
5 | % S. Westermann, October 2020
6 | %========================================================================
7 |
8 | classdef IA_HEAT11_WATER11_RichardsEq_SNOW < IA_WATER & IA_HEAT
9 |
10 | methods
11 |
12 | function get_boundary_condition_m(ia_heat_water, tile)
13 | get_boundary_condition_HEAT_m(ia_heat_water);
14 | get_boundary_condition_RichardsEq_SNOW_m(ia_heat_water);
15 | end
16 |
17 | %SNOW
18 | function get_IA_CHILD_boundary_condition_u(ia_heat_water, tile)
19 | get_boundary_condition_HEAT_IA_CHILD(ia_heat_water);
20 | get_boundary_condition_RichardsEq_SNOW_m(ia_heat_water);
21 | end
22 |
23 | end
24 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER11_RichardsEq_SNOW_XICE.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction and water fluxes between a SNOW class
3 | % and a GROUND class with Richards equation water and excess ice
4 | % contains function for SNOW CHILD phase
5 | % S. Westermann, October 2020
6 | %========================================================================
7 |
8 | classdef IA_HEAT11_WATER11_RichardsEq_SNOW_XICE < IA_HEAT11_WATER11_SNOW_XICE
9 |
10 | methods
11 |
12 | function get_boundary_condition_m(ia_heat_water, tile)
13 | get_boundary_condition_HEAT_m(ia_heat_water);
14 | get_boundary_condition_RichardsEq_Xice_SNOW_m(ia_heat_water);
15 | end
16 |
17 |
18 | function get_IA_CHILD_boundary_condition_u(ia_heat_water, tile)
19 | get_boundary_condition_HEAT_IA_CHILD(ia_heat_water);
20 | get_boundary_condition_RichardsEq_Xice_SNOW_m(ia_heat_water);
21 | end
22 |
23 | % remove_excessWater_CHILD(ia_heat_water) handled in IA_HEAT11_WATER11_SNOW_XICE
24 |
25 |
26 | end
27 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER11_SNOW.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction and water fluxes between a SNOW class
3 | % and a GROUND class with bucket water
4 | % contains function for SNOW CHILD phase
5 | % S. Westermann, October 2020
6 | %========================================================================
7 |
8 | classdef IA_HEAT11_WATER11_SNOW < IA_WATER & IA_HEAT
9 |
10 | methods
11 |
12 | function get_boundary_condition_m(ia_heat_water, tile)
13 | get_boundary_condition_HEAT_m(ia_heat_water);
14 | get_boundary_condition_BUCKET_SNOW_m(ia_heat_water);
15 | end
16 |
17 | %SNOW
18 | function get_IA_CHILD_boundary_condition_u(ia_heat_water, tile)
19 | get_boundary_condition_HEAT_IA_CHILD(ia_heat_water);
20 | get_boundary_condition_BUCKET_SNOW_m(ia_heat_water);
21 | end
22 |
23 | end
24 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER11_SNOW_LAKE.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction and water fluxes between a SNOW class
3 | % and a LAKE class
4 | % contains function for SNOW CHILD phase
5 | % S. Westermann, October 2020
6 | %========================================================================
7 |
8 | classdef IA_HEAT11_WATER11_SNOW_LAKE < IA_WATER & IA_HEAT
9 |
10 | methods
11 |
12 | function get_boundary_condition_m(ia_heat_water, tile)
13 | get_boundary_condition_HEAT_m(ia_heat_water);
14 | %MODIFY
15 | %ia_heat_water.PREVIOUS.TEMP.F_lb_water = 0;
16 | %ia_heat_water.PREVIOUS.TEMP.F_lb_water_energy = 0;
17 | %ia_heat_water.NEXT.TEMP.F_ub_water = 0;
18 | %ia_heat_water.NEXT.TEMP.F_ub_water_energy = 0;
19 | %get_boundary_condition_BUCKET_SNOW_m(ia_heat_water);
20 | get_boundary_condition_BUCKET_SNOW_LAKE_m(ia_heat_water);
21 | end
22 |
23 | %SNOW
24 | function get_IA_CHILD_boundary_condition_u(ia_heat_water, tile)
25 | get_boundary_condition_HEAT_IA_CHILD(ia_heat_water);
26 | %ia_heat_water.PREVIOUS.TEMP.F_lb_water = 0;
27 | %ia_heat_water.PREVIOUS.TEMP.F_lb_water_energy = 0;
28 | %ia_heat_water.NEXT.TEMP.F_ub_water = 0;
29 | %ia_heat_water.NEXT.TEMP.F_ub_water_energy = 0;
30 | %get_boundary_condition_BUCKET_SNOW_m(ia_heat_water);
31 | get_boundary_condition_BUCKET_SNOW_LAKE_m(ia_heat_water);
32 | end
33 |
34 | function remove_excessWater_CHILD(ia_heat_water) %move excessWater from SNOW to water of PARENT, 0 energy transfer since meltwater must be zero
35 | ia_heat_water.NEXT.STATVAR.waterIce(1) = ia_heat_water.NEXT.STATVAR.waterIce(1) + ia_heat_water.PREVIOUS.STATVAR.excessWater;
36 | ia_heat_water.NEXT.STATVAR.water(1) = ia_heat_water.NEXT.STATVAR.water(1) + ia_heat_water.PREVIOUS.STATVAR.excessWater;
37 | ia_heat_water.NEXT.STATVAR.layerThick(1) = ia_heat_water.NEXT.STATVAR.layerThick(1) + ia_heat_water.PREVIOUS.STATVAR.excessWater ./ ia_heat_water.NEXT.STATVAR.area(1);
38 | ia_heat_water.PREVIOUS.STATVAR.excessWater = 0;
39 | end
40 |
41 | end
42 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT11_WATER11_SNOW_XICE.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction and water fluxes between a SNOW class
3 | % and a GROUND class with bucket water and excess ice
4 | % contains function for SNOW CHILD phase
5 | % S. Westermann, October 2020
6 | %========================================================================
7 |
8 | classdef IA_HEAT11_WATER11_SNOW_XICE < IA_WATER & IA_HEAT
9 |
10 | methods
11 |
12 | function get_boundary_condition_m(ia_heat_water, tile)
13 | get_boundary_condition_HEAT_m(ia_heat_water);
14 | get_boundary_condition_BUCKET_SNOW_XICE_m(ia_heat_water);
15 | end
16 |
17 | %SNOW
18 | function get_IA_CHILD_boundary_condition_u(ia_heat_water, tile)
19 | get_boundary_condition_HEAT_IA_CHILD(ia_heat_water);
20 | get_boundary_condition_BUCKET_SNOW_XICE_m(ia_heat_water);
21 | end
22 |
23 | function remove_excessWater_CHILD(ia_heat_water) %move excessWater from SNOW to water and Xwater from PARENT, 0 energy transfer since meltwater must be zero
24 |
25 | space_left = max(0,ia_heat_water.NEXT.STATVAR.layerThick(1) .* ia_heat_water.NEXT.STATVAR.area(1) - ia_heat_water.NEXT.STATVAR.mineral(1) ...
26 | - ia_heat_water.NEXT.STATVAR.organic(1) - ia_heat_water.NEXT.STATVAR.waterIce(1) - ia_heat_water.NEXT.STATVAR.XwaterIce(1));
27 | water_in = min(space_left, ia_heat_water.PREVIOUS.STATVAR.excessWater);
28 | Xwater_in = max(0, ia_heat_water.PREVIOUS.STATVAR.excessWater - water_in);
29 |
30 | ia_heat_water.NEXT.STATVAR.waterIce(1) = ia_heat_water.NEXT.STATVAR.waterIce(1) + water_in;
31 | ia_heat_water.NEXT.STATVAR.XwaterIce(1) = ia_heat_water.NEXT.STATVAR.XwaterIce(1) + Xwater_in;
32 | ia_heat_water.NEXT.STATVAR.Xwater(1) = ia_heat_water.NEXT.STATVAR.Xwater(1) + Xwater_in;
33 | ia_heat_water.NEXT.STATVAR.layerThick(1) = ia_heat_water.NEXT.STATVAR.layerThick(1) + Xwater_in ./ ia_heat_water.NEXT.STATVAR.area(1);
34 | ia_heat_water.NEXT.STATVAR.energy(1,1) = ia_heat_water.NEXT.STATVAR.energy(1,1) + ia_heat_water.PREVIOUS.STATVAR.excessWater_energy;
35 | ia_heat_water.PREVIOUS.STATVAR.excessWater = 0;
36 | ia_heat_water.PREVIOUS.STATVAR.excessWater_energy = 0;
37 | end
38 |
39 | end
40 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_HEAT_TTOP.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction between two GROUND
3 | % classes without water cycle
4 | % contains function for SNOW CHILD phase
5 | % S. Westermann, October 2020
6 | %========================================================================
7 |
8 | classdef IA_HEAT_TTOP < IA_HEAT
9 |
10 | methods
11 |
12 | function get_boundary_condition_m(ia_heat, tile)
13 | get_boundary_condition_HEAT_TTOP_m(ia_heat);
14 | end
15 |
16 |
17 | end
18 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_MULTI_TILE10.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for multiTile class above a normal class
3 | % S. Westermann, October 2020
4 | %========================================================================
5 |
6 | classdef IA_MULTI_TILE10 < IA_BASE
7 |
8 | properties
9 | IA_MULTI_TILE
10 | end
11 |
12 |
13 | methods
14 |
15 | function finalize_init(ia_multiTile, tile)
16 | for i=1:size(ia_multiTile.PREVIOUS.STATVAR.SUB_TILES_BOTTOM,1)
17 | ia_multiTile.IA_MULTI_TILE{i,1} = get_IA_class(class(ia_multiTile.PREVIOUS.STATVAR.SUB_TILES_BOTTOM{i,1}.PREVIOUS), class(ia_multiTile.NEXT));
18 | ia_multiTile.PREVIOUS.STATVAR.SUB_TILES_BOTTOM{i,1}.PREVIOUS.IA_NEXT = ia_multiTile.IA_MULTI_TILE{i,1};
19 | ia_multiTile.IA_MULTI_TILE{i,1}.PREVIOUS = ia_multiTile.PREVIOUS.STATVAR.SUB_TILES_BOTTOM{i,1}.PREVIOUS;
20 | ia_multiTile.IA_MULTI_TILE{i,1}.NEXT = ia_multiTile.NEXT;
21 | end
22 | end
23 |
24 | function get_boundary_condition_m(ia_multiTile, tile)
25 | for i = 1:size(ia_multiTile.IA_MULTI_TILE,1)
26 | ia_multiTile.NEXT.IA_PREVIOUS = ia_multiTile.IA_MULTI_TILE{i,1};
27 | get_boundary_condition_m(ia_multiTile.IA_MULTI_TILE{i,1}, tile);
28 | end
29 | ia_multiTile.NEXT.IA_PREVIOUS = ia_multiTile;
30 | end
31 |
32 | end
33 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_SEB11_vegetation_NOT_USED.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for surface energy balance of a GROUND
3 | % class below a shading VEGETATION class
4 | % R. B. Zwegiel, August 2021
5 | %========================================================================
6 |
7 | classdef IA_HEAT01_SEB11_vegetation < IA_SEB % IA_WATER & IA_HEAT
8 |
9 | methods
10 |
11 | function get_boundary_condition_m(ia_heat_seb, tile)
12 | % Get sensible- & latent fluxes as if lower class was top_class
13 | ia_heat_seb = get_boundary_condition_Qh_m(ia_heat_seb, tile);
14 | ia_heat_seb = get_boundary_condition_Qe_m(ia_heat_seb, tile);
15 |
16 | % add fluxes to uppermost cell (ratiative fluxes are added by penetration)
17 | ia_heat_seb.NEXT.TEMP.d_energy(1) = ia_heat_seb.NEXT.TEMP.d_energy(1) + (-ia_heat_seb.NEXT.STATVAR.Qh - ia_heat_seb.NEXT.STATVAR.Qe) .* ia_heat_seb.NEXT.STATVAR.area(1);
18 | end
19 |
20 |
21 |
22 | end
23 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/IA_thermRadiation11.m:
--------------------------------------------------------------------------------
1 | %========================================================================
2 | % CryoGrid INTERACTION (IA) class for heat conduction between two GROUND
3 | % classes without water cycle
4 | % contains function for SNOW CHILD phase
5 | % S. Westermann, October 2020
6 | %========================================================================
7 |
8 | classdef IA_thermRadiation11 < IA_BASE
9 |
10 | methods
11 |
12 | function get_boundary_condition_m(ia_heat, tile)
13 | stratigraphy1 = ia_heat.PREVIOUS;
14 | stratigraphy2 = ia_heat.NEXT;
15 | Isource1 = stratigraphy1.PARA.epsilon .* stratigraphy1.CONST.sigma.*(stratigraphy1.STATVAR.T(end) + stratigraphy1.CONST.Tmfw).^4;
16 | Isource2 = stratigraphy2.PARA.epsilon .* stratigraphy1.CONST.sigma.*(stratigraphy2.STATVAR.T(1) + stratigraphy1.CONST.Tmfw).^4;
17 | %residual = (stratigraphy2.PARA.epsilon -1) .* LW_out_strat1 + (stratigraphy1.PARA.epsilon -1) .* LW_out_strat2;
18 | LW_out_strat1 = - Isource1 + Isource1 .* (1 - stratigraphy2.PARA.epsilon) .* stratigraphy1.PARA.epsilon ./ (1 - (1 - stratigraphy1.PARA.epsilon) .* (1 - stratigraphy2.PARA.epsilon));
19 | LW_out_strat2 = - Isource2 + Isource2 .* (1 - stratigraphy1.PARA.epsilon) .* stratigraphy2.PARA.epsilon ./ (1 - (1 - stratigraphy1.PARA.epsilon) .* (1 - stratigraphy2.PARA.epsilon));
20 |
21 | stratigraphy1.TEMP.d_energy(end) = stratigraphy1.TEMP.d_energy(end) + (LW_out_strat1 - LW_out_strat2) .* stratigraphy1.STATVAR.area(end);
22 | stratigraphy2.TEMP.d_energy(1) = stratigraphy2.TEMP.d_energy(1) + (LW_out_strat2 - LW_out_strat1) .* stratigraphy2.STATVAR.area(1);
23 |
24 | stratigraphy1.TEMP.d_energy(end) = stratigraphy1.TEMP.d_energy(end) + stratigraphy1.PARA.exchangeAir .* tile.FORCING.TEMP.wind .* (-stratigraphy1.STATVAR.T(end) + tile.FORCING.TEMP.Tair);
25 | stratigraphy2.TEMP.d_energy(1) = stratigraphy2.TEMP.d_energy(1) + stratigraphy1.PARA.exchangeAir .* tile.FORCING.TEMP.wind .* (-stratigraphy2.STATVAR.T(1) + tile.FORCING.TEMP.Tair);
26 | end
27 |
28 | % %SNOW
29 | % function get_IA_CHILD_boundary_condition_u(ia_heat, tile)
30 | % get_boundary_condition_HEAT_IA_CHILD(ia_heat);
31 | % end
32 |
33 | end
34 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/interaction_matrix.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_2_full_classes/INTERACTION/interaction_matrix.xlsx
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/INTERACTION/~$interaction_matrix.xlsx:
--------------------------------------------------------------------------------
1 | Sebastian Westermann S e b a s t i a n W e s t e r m a n n
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/CLM_Vegetation.m:
--------------------------------------------------------------------------------
1 | % classdef CLM_Vegetation
2 | % properties
3 | % mlcanopyinst %constants
4 | % end
5 | %
6 | % methods
7 |
8 | %mandatory functions for each module
9 | % vegetation = initialize_mlcanopyinst(FORCING);
10 |
11 |
12 | % %upper boundry condition
13 | % function forest = get_boundary_condition_u(forest, forcing)
14 | % forest = surface_energy_balance(forest, forcing);
15 | % forest.TEMP.rainfall = forcing.TEMP.rainfall ./1000 ./(24.*3600);
16 | % end
17 | %
18 | % %lower boundry condition
19 | % function forest = get_boundary_condition_l(forest)
20 | % forest.TEMP.F_lb = get_F_lb(forest);
21 | % end
22 | %
23 | %
24 | % function forest = get_derivatives_prognostic(forest)
25 | % forest.TEMP.d_energy = get_derivative_energy(forest);
26 | % end
27 | %
28 | % function timestep = get_timestep(forest) %could involve check for several state variables
29 | % timestep = forest.PARA.d_e_max ./ (max(abs(forest.TEMP.d_energy) ./ forest.STATVAR.D));
30 | %
31 | % end
32 | %
33 | % function forest = advance_prognostic(forest, timestep) %real timestep derived as minimum of several classes in [sec] here!
34 | % forest.STATVAR.energy = forest.STATVAR.energy + timestep .* forest.TEMP.d_energy;
35 | % end
36 | %
37 | % function forest = compute_diagnostic_first_cell(forest, forcing)
38 | % forest = L_star(forest, forcing);
39 | % end
40 | %
41 | % function forest = compute_diagnostic(forest)
42 | % forest = get_T_water(forest);
43 | % forest.STATVAR.cond = conductivity_veg(forest);
44 | % % forest = L_star(forest, forcing);
45 | % end
46 | %
47 | % % function [trigger, forest] = check_triggers (forest, trigger)
48 | % if forest.STATVAR.swe > forest.PARA.swe_per_cell./2
49 | % snow_energy = -forest.STATVAR.swe .* forest.CONST.Lf + forest.STATVAR.T(1) .* forest.STATVAR.swe .* forest.CONST.c_i;
50 | % trigger=[trigger; {CREATE_SNOW(forest.STATVAR.swe, snow_energy, forest.STATVAR.T(1), forest.STATVAR.water_reservoir, forest.STATVAR.Lstar)}];
51 | % forest.STATVAR.energy(1) = forest.STATVAR.energy(1) - snow_energy;
52 | % forest.STATVAR.swe = 0;
53 | % forest.STATVAR.water_reservoir = 0;
54 | % forest.TEMP.snowfall=0;
55 | % forest.TEMP.rainfall = 0;
56 | % forest.TEMP.snow_energy = 0;
57 | % end
58 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/GetBeta.m:
--------------------------------------------------------------------------------
1 | function [beta] = GetBeta (beta_neutral, LcL)
2 | %
3 | % DESCRIPTION:
4 | % Calculate beta = u* / u(h) for current Obukhov length
5 | %
6 | % ARGUMENTS:
7 | % Input:
8 |
9 |
10 |
11 | % real(r8), intent(in) :: beta_neutral % Neutral value for beta = u*/u(h), ~0.3-0.5
12 | % real(r8), intent(in) :: LcL % Canopy density scale (Lc) / Obukhov length (obu)
13 | % real(r8), intent(out) :: beta % Value of u*/u(h) at canopy top
14 | %
15 | % LOCAL VARIABLES:
16 | %aa, bb, cc, dd, qq, rr % Terms for quadratic or cubic solution
17 | %LcL_val % LcL with limits applied
18 | %---------------------------------------------------------------------
19 |
20 | LcL_val = LcL;
21 |
22 | if (LcL_val <= 0 )
23 |
24 | % Unstable case: quadratic equation for beta^2 at LcL_val
25 |
26 | bb = 16 .* LcL_val.* beta_neutral^4 ;
27 | beta = sqrt( 0.5.*(-bb + sqrt(bb^2 + 4 .* beta_neutral^4)) );
28 |
29 | else
30 |
31 | % Stable case: cubic equation for beta at LcL_val
32 |
33 | aa = 5 .* LcL_val;
34 | bb = 0 ;
35 | cc = 1 ;
36 | dd = -beta_neutral;
37 | qq = (2.*bb^3 - 9.*aa*bb*cc + 27.*(aa^2)*dd)^2 - 4.*(bb^2 - 3.*aa*cc)^3;
38 | qq = sqrt(qq);
39 | rr = 0.5 .* (qq + 2.*bb^3 - 9.*aa*bb*cc + 27.*(aa^2)*dd);
40 | rr = rr^(1 /3 );
41 | beta = -(bb+rr)/(3.*aa) - (bb^2 - 3.*aa*cc)/(3.*aa*rr) ;
42 |
43 | end
44 |
45 | beta = min(0.50 , max(beta,0.20));
46 |
47 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/GetPrSc.m:
--------------------------------------------------------------------------------
1 | function [Pr] = GetPrSc (beta_neutral, beta_neutral_max, LcL)
2 | %
3 | % DESCRIPTION:
4 | % Calculate turbulent Prandlt number (Pr) and Schmidt number (Sc) at canopy
5 | % top for current Obukhov length
6 | %
7 | % ARGUMENTS:
8 | % Input:
9 | % beta_neutral_max = 0.35 ;
10 | % beta_neutral = 0.3;
11 | % LcL = 1;
12 |
13 | % Output:
14 | %Pr %turbulent Prandlt number (Pr)
15 | %Sc % Schmidt number at canopy top
16 |
17 | % LOCAL VARIABLES:
18 | Prn = 0.5; % Neutral value for Pr
19 | Prvr = 0.3; % Magnitude of variation of Pr with stability
20 | Prsc = 2.0; % Scale of variation of Pr with stability
21 |
22 | Scn = Prn; % Neutral value for Sc
23 | Scvr = Prvr; % Magnitude of variation of Sc with stability
24 | Scsc = Prsc; % Scale of variation of Sc with stability
25 | %---------------------------------------------------------------------
26 |
27 | Pr = Prn + Prvr.* tanh(Prsc*LcL);
28 | Pr = (1 - beta_neutral/beta_neutral_max).* 1 + beta_neutral/beta_neutral_max*Pr;
29 |
30 | Sc = Scn + Scvr.* tanh(Scsc*LcL);
31 | Sc = (1 - beta_neutral/beta_neutral_max).* 1 + beta_neutral/beta_neutral_max*Sc;
32 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/LatVap.m:
--------------------------------------------------------------------------------
1 | function [lambda] = LatVap (t, vegetation)
2 | %DESCRIPTION:
3 | %Latent heat of vaporization in relation to air temperature
4 |
5 | %USES:
6 | % tfrz = vegetation.physcon.tfrz; %use clm_varcon % Freezing point of water (K)
7 | % mmh2o = vegetation.physcon.mmh2o; %use clm_varcon
8 | % hfus = vegetation.physcon.hfus; %use clm_varcon
9 | % hvap = vegetation.physcon.hvap; %use clm_varcon
10 |
11 | %ARGUMENTS:
12 | % t = 200; % Temperature (K)
13 |
14 | %LOCAL VARIABLES:
15 | % lambda % Molar latent heat of vaporization (J/mol)
16 | %---------------------------------------------------------------------
17 |
18 | lambda = vegetation.physcon.hvap; % Used in CLM (J/kg)
19 | if (t <= vegetation.physcon.tfrz)
20 | lambda = lambda + vegetation.physcon.hfus; % Add latent heat of fusion (J/kg)
21 | end
22 | lambda = lambda * vegetation.physcon.mmh2o; % Molar latent heat of vaporization (J/mol)
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/LeafFluxes.m:
--------------------------------------------------------------------------------
1 |
2 | function [vegetation] = LeafFluxes (vegetation, p, ic, il)
3 | % DESCRIPTION:
4 | % Leaf temperature, energy fluxes, photosynthesis, and stomatal conductance
5 |
6 | % gstyp = vegetation.physcon.gstyp;
7 | % dpai = vegetation.canopy.dpai; % Layer plant area index (m2/m2)
8 | % tleaf = vegetation.mlcanopyinst.tleaf; % Leaf temperature (K)
9 |
10 | if (vegetation.canopy.dpai(p,ic) > 0)
11 | % Calculate fluxes for leaf layers using TleafFunc for Ball-Berry style
12 | % stomatal model or StomataOptimization for water-use efficiency
13 | % optimization model. These routines calculate leaf temperature and
14 | % stomatal conductance simultaneously. If leaf_temp_iter = false, the leaf
15 | % temperature calculation is turned off and the stomatal conductance
16 | % routines use leaf temperature from the previous sub-timestep.
17 |
18 | if (vegetation.params.gstyp <= 1)
19 | % Initial estimates for leaf temperature
20 | t0 = vegetation.mlcanopyinst.tleaf(p,ic,il) - 1 ; % Initial estimate for leaf temperature (K)
21 | t1 = vegetation.mlcanopyinst.tleaf(p,ic,il) + 1 ; % Initial estimate for leaf temperature (K)
22 | tol = 0.1; % Accuracy tolerance for tleaf (K)
23 |
24 | % Solve for tleaf: Use TleafFunc to iterate leaf temperature, energy fluxes,
25 | % photosynthesis and stomatal conductance. This temperature is refined to an
26 | % accuracy of tol. Do not use the returned value (dummy), and instead use
27 | % the tleaf calculated in the final call to TleafFunc.
28 | func_name = 'TleafFunc'; % The function name
29 | vegetation = hybrid_root(func_name, vegetation, p, ic, il, t0, t1, tol);
30 | % FORTRAN: dummy = hybrid ('LeafFluxes', p, ic, il, mlcanopy_inst, TleafFunc, t0, t1, tol)
31 |
32 | elseif (vegetation.params.gstyp == 2)
33 | % Iterate leaf temperature, flux calculations, and stomatal conductance
34 | % using water-use efficiency optimization and cavitation check
35 | vegetation = StomataOptimization(vegetation,p,ic,il);
36 | end
37 |
38 | else % non-leaf layer
39 | % Zero out fluxes
40 | if (vegetation.params.gstyp <= 1)
41 | vegetation = TleafFunc(vegetation,p,ic,il,vegetation.mlcanopyinst.tair(p,ic));
42 | elseif (vegetation.params.gstyp == 2)
43 | vegetation = StomataOptimization(vegetation,p,ic,il);
44 | end
45 | end
46 |
47 | % vegetation.mlcanopyinst.t1 = t1;
48 | end
49 |
50 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/LeafTemperatureMod.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/LeafTemperatureMod.m
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/LeafWaterPotential.m:
--------------------------------------------------------------------------------
1 | function [vegetation, leafwp] = LeafWaterPotential (vegetation,p,ic,il,leafwp)
2 | % %ARGUMENTS:
3 | % p % Patch index for CLM g/l/c/p hierarchy
4 | % ic % Aboveground layer index
5 | % il % Sunlit (1) or shaded (2) leaf index
6 | % leafwp % Leaf water potential (MPa)
7 | % mlcanopy_inst
8 |
9 | % %LOCAL VARIABLES:
10 | % dtime % Model time step (s)
11 | % y0 % Leaf water potential at beginning of timestep (MPa)
12 | % dy % Change in leaf water potential (MPa)
13 | % a, b % Intermediate calculation
14 |
15 | vegetation.physcon.head = vegetation.physcon.denh20*vegetation.physcon.grav*1.e-06;
16 | % head = vegetation.physcon.head;
17 | % capac = vegetation.pftcon.capac(p); % Plant capacitance (mmol H2O/m2 leaf area/MPa)
18 | % psis = vegetation.mlcanopyinst.psis(p); % Weighted soil water potential (MPa)
19 | % zs = vegetation.mlcanopyinst.zs(p,ic); % Canopy height for scalar concentration and source (m)
20 | % % dpai = vegetation.canopy.dpai(p,ic); % Layer plant area index (m2/m2)
21 | % lsc = vegetation.mlcanopyinst.lsc(p,ic); % Leaf-specific conductance for canopy layer (mmol H2O/m2 leaf/s/MPa)
22 | % trleaf = vegetation.mlcanopyinst.trleaf(p,ic,il); % Leaf transpiration flux (mol H2O/m2 leaf/s)
23 | % leafwp = vegetation.mlcanopyinst.leafwp(p,ic,il);
24 |
25 | % Get step size
26 | dtime = vegetation.params.dtime_sub;
27 |
28 | % Change in leaf water potential is: dy / dt = (a - y) / b. The integrated change
29 | % over a full model timestep is: dy = (a - y0) * (1 - exp(-dt/b))
30 |
31 | if (vegetation.canopy.dpai(p,ic) > 0) % leaf layer
32 | y0 = leafwp;
33 | a = vegetation.mlcanopyinst.psis(p) - vegetation.physcon.head .* vegetation.mlcanopyinst.zs(p,ic) - 1000. .* vegetation.mlcanopyinst.trleaf(p,ic,il) ./ vegetation.mlcanopyinst.lsc(p,ic);
34 | b = vegetation.leaf.capac(p) ./ vegetation.mlcanopyinst.lsc(p,ic);
35 | dy = (a-y0) .* (1.-exp(-dtime./b));
36 | leafwp = y0 + dy;
37 | else % non-leaf layer
38 | leafwp = 0;
39 | end
40 | %vegetation.mlcanopyinst.leafwp = leafwp;
41 |
42 | end
43 |
44 |
45 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/PlantResistance.m:
--------------------------------------------------------------------------------
1 | function [vegetation] = PlantResistance (vegetation) %, p, ic
2 | %num_exposedvegp, filter_exposedvegp, mlcanopy_inst, shr_kind, ic, p, f)
3 | %
4 | % %DESCRIPTION:
5 | % Calculate whole-plant leaf-specific conductance (soil-to-leaf)
6 |
7 | % %LOCAL VARIABLES:
8 | % integer :: f % Filter index
9 | % p = vegetation.mlcanopyinst.p; % Patch index for CLM g/l/c/p hierarchy
10 | % ic = 1; % Aboveground layer index
11 | % real(r8) :: rplant % Aboveground plant hydraulic resistance (MPa.s.m2/mmol H2O)
12 |
13 | % ncan = vegetation.mlcanopyinst.ncan;
14 | %---------------------------------------------------------------------
15 | %Input
16 | % gplant % Stem (xylem-to-leaf) hydraulic conductance (mmol H2O/m2 leaf area/s/MPa)
17 | % dpai % Layer plant area index (m2/m2)
18 | % zs % Canopy height for scalar concentration and source (m)
19 | % rsoil % Soil hydraulic resistance (MPa.s.m2/mmol H2O)
20 |
21 | for f = 1:vegetation.canopy.num_exposedvegp
22 | p = vegetation.canopy.filter_exposedvegp(f);
23 | for ic = vegetation.canopy.nbot(p):vegetation.mlcanopyinst.ncan(p) %Fortran 1:ncan
24 |
25 | if (vegetation.canopy.dpai(p,ic) > 0) % leaf layer
26 |
27 | % Aboveground plant stem resistance, xylem-to-leaf (MPa.s.m2/mmol H2O)
28 |
29 | %rplant = zs(p,ic) / gplant(p) % gplant is conductivity (mmol/m/s/MPa)
30 | rplant = 1. ./ vegetation.leaf.gplant(p); % gplant is conductance (mmol/m2/s/MPa)
31 |
32 | % Leaf specific conductance, soil-to-leaf (mmol H2O/m2/s/MPa)
33 |
34 | %rsoil calculated in SoilResistance
35 | vegetation.mlcanopyinst.lsc(p,ic) = 1. ./ (vegetation.mlcanopyinst.rsoil(p) + rplant);
36 |
37 | else % non-leaf layer
38 |
39 | vegetation.mlcanopyinst.lsc(p,ic) = 0.;
40 |
41 | end
42 |
43 | end
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/Satvap.m:
--------------------------------------------------------------------------------
1 | function [esat, desat] = Satvap (t)
2 |
3 | % %ARGUMENTS:
4 | % tfrz = vegetation.physcon.tfrz;
5 |
6 | % Compute saturation vapor pressure and change in saturation vapor pressure
7 | % with respect to temperature. Polynomial approximations are from:
8 | % Flatau et al. (1992) Polynomial fits to saturation vapor pressure.
9 | % Journal of Applied Meteorology 31:1507-1513. Input temperature is Celsius.
10 |
11 | % --- For water vapor (temperature range is 0C to 100C)
12 |
13 | a0 = 6.11213476; b0 = 0.444017302;
14 | a1 = 0.444007856; b1 = 0.286064092e-01;
15 | a2 = 0.143064234e-01; b2 = 0.794683137e-03;
16 | a3 = 0.264461437e-03; b3 = 0.121211669e-04;
17 | a4 = 0.305903558e-05; b4 = 0.103354611e-06;
18 | a5 = 0.196237241e-07; b5 = 0.404125005e-09;
19 | a6 = 0.892344772e-10; b6 = -0.788037859e-12;
20 | a7 = -0.373208410e-12; b7 = -0.114596802e-13;
21 | a8 = 0.209339997e-15; b8 = 0.381294516e-16;
22 |
23 | % --- For ice (temperature range is -75C to 0C)
24 |
25 | c0 = 6.11123516; d0 = 0.503277922;
26 | c1 = 0.503109514; d1 = 0.377289173e-01;
27 | c2 = 0.188369801e-01; d2 = 0.126801703e-02;
28 | c3 = 0.420547422e-03; d3 = 0.249468427e-04;
29 | c4 = 0.614396778e-05; d4 = 0.313703411e-06;
30 | c5 = 0.602780717e-07; d5 = 0.257180651e-08;
31 | c6 = 0.387940929e-09; d6 = 0.133268878e-10;
32 | c7 = 0.149436277e-11; d7 = 0.394116744e-13;
33 | c8 = 0.262655803e-14; d8 = 0.498070196e-16;
34 |
35 | % --- Limit temperature to -75C to 100C
36 | %tc = t-vegetation.physcon.tfrz;
37 | tc = t-273.15;
38 | if (tc > 100.)
39 | tc = 100.;
40 | end
41 | if (tc < -75.)
42 | tc = -75.0;
43 | end
44 |
45 | % --- Saturation vapor pressure (esat, mb) and derivative (desat, mb)
46 |
47 | if (tc >= 0.)
48 | esat = a0 + tc.*(a1 + tc.*(a2 + tc.*(a3 + tc.*(a4 ...
49 | + tc.*(a5 + tc.*(a6 + tc.*(a7 + tc.*a8)))))));
50 | desat = b0 + tc.*(b1 + tc.*(b2 + tc.*(b3 + tc.*(b4 ...
51 | + tc.*(b5 + tc.*(b6 + tc.*(b7 + tc.*b8)))))));
52 | else
53 | esat = c0 + tc.*(c1 + tc.*(c2 + tc.*(c3 + tc.*(c4 ...
54 | + tc.*(c5 + tc.*(c6 + tc.*(c7 + tc.*c8)))))));
55 | desat = d0 + tc.*(d1 + tc.*(d2 + tc.*(d3 + tc.*(d4 ...
56 | + tc.*(d5 + tc.*(d6 + tc.*(d7 + tc.*d8)))))));
57 | end
58 |
59 | % --- Convert from mb to Pa
60 |
61 | esat = esat .* 100;
62 | desat = desat .* 100;
63 | end
64 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/SoilFluxesMultilayer.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/SoilFluxesMultilayer.m
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/SoilResistance.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/SoilResistance.m
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/StomataFluxes.m:
--------------------------------------------------------------------------------
1 | %-----------------------------------------------------------------------
2 | function [vegetation, leafwp] = StomataFluxes (vegetation,p,ic,il,gs_val,leafwp)
3 |
4 | % DESCRIPTION:
5 | % Calculate leaf temperature, energy fluxes, photosynthesis, and leaf
6 | % water potential for a specificed stomatal conductance (gs_val)
7 |
8 | % leaf_temp_iter = vegetation.physcon.leaf_temp_iter;
9 |
10 | % % ARGUMENTS:
11 | % leafwp % Leaf water potential (MPa)
12 | % gs = vegetation.mlcanopyinst.gs;
13 | %---------------------------------------------------------------------
14 |
15 | % gs_val(p,ic,il) = vegetation.mlcanopyinst.gs(p,ic,il); % Leaf stomatal conductance (mol H2O/m2 leaf/s)
16 |
17 | % Use specified gs (gs_val)
18 | vegetation.mlcanopyinst.gs(p,ic,il) = gs_val;
19 |
20 | % vegetation.mlcanopyinst.gs = gs;
21 | % Leaf temperature and energy fluxes
22 |
23 | %if %(vegetation.physcon.leaf_temp_iter == 1)
24 | [vegetation] = LeafTemperatureMod (vegetation,p,ic,il);
25 | %end
26 |
27 | % Leaf photosynthesis
28 |
29 | [vegetation] = LeafPhotosynthesis (vegetation,p,ic,il);
30 |
31 | % Leaf transpiration
32 |
33 | % if (~ leaf_temp_iter)
34 | [vegetation] = LeafTranspiration (vegetation,p,ic,il);
35 | % end
36 |
37 | % Leaf water potential
38 | [vegetation, leafwp] = LeafWaterPotential(vegetation,p,ic,il,leafwp);
39 |
40 | end
41 |
42 |
43 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/TleafFunc.m:
--------------------------------------------------------------------------------
1 | function [vegetation, tleaf_dif] = TleafFunc (vegetation,p,ic,il,tleaf_val)
2 | %(p, ic, il, mlcanopy_inst, tleaf_val, shr_kind, abortutils, clm_varctl,CanopyFluxesMultilayerType, LeafPhotosynthesisMod, LeafTemperatureMod)
3 | % DESCRIPTION:
4 | % Calculate leaf fluxes for an input leaf temperature (tleaf_val) and
5 | % compare the new temperature to the prior temperature. This function
6 | % equals zero when tleaf does not change between iterations.
7 |
8 | % USES:
9 | % iulog = 1; % clm_varctl
10 |
11 | % leaf_temp_iter = vegetation.physcon.leaf_temp_iter; % clm_varctl
12 | % p = vegetation.mlcanopyinst.p; % Patch index for CLM g/l/c/p hierarchy
13 | % ic = 1;%vegetation.mlcanopyinst.ic; % Canopy layer index
14 | % il = 1;%vegetation.mlcanopyinst.il; % Sunlit (1) or shaded (2) leaf index
15 |
16 | % ARGUMENTS:
17 | % tleaf = vegetation.mlcanopyinst.tleaf; % Input value for tleaf
18 |
19 | % LOCAL VARIABLES:
20 | % tleaf_dif = 1; % Difference in tleaf
21 | %---------------------------------------------------------------------
22 |
23 | % associate (tleaf => mlcanopy_inst.tleaf) % Leaf temperature (K)
24 |
25 | if (tleaf_val < 0)
26 | disp ('TleafFunc error')
27 | end
28 |
29 | vegetation.mlcanopyinst.tleaf(p,ic,il) = tleaf_val;
30 |
31 | % Leaf photosynthesis and stomatal conductance
32 |
33 | [vegetation] = LeafPhotosynthesis(vegetation,p,ic,il);
34 |
35 | % Leaf temperature and energy fluxes
36 |
37 | [vegetation] = LeafTemperatureMod(vegetation,p,ic,il);
38 |
39 | % --- Compare with prior value for leaf temperature
40 |
41 | tleaf_dif = vegetation.mlcanopyinst.tleaf(p,ic,il) - tleaf_val;
42 |
43 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/data.txt:
--------------------------------------------------------------------------------
1 | layer lai sun sha sun sha
2 | 1 0.0250 183.769348 59.385906 8.923815 4.046033
3 | 2 0.0750 182.049240 57.665783 8.904988 4.027205
4 | 3 0.1250 180.398834 56.015404 8.882613 4.004831
5 | 4 0.1750 178.816208 54.432762 8.856857 3.979075
6 | 5 0.2250 177.299393 52.915943 8.827874 3.950092
7 | 6 0.2750 175.846603 51.463150 8.795814 3.918031
8 | 7 0.3250 174.456085 50.072632 8.760817 3.883035
9 | 8 0.3750 173.126190 48.742733 8.723022 3.845241
10 | 9 0.4250 171.855362 47.471909 8.682557 3.804775
11 | 10 0.4750 170.642105 46.258671 8.639544 3.761763
12 | 11 0.5250 169.485062 45.101616 8.594101 3.716319
13 | 12 0.5750 168.382858 43.999424 8.546338 3.668556
14 | 13 0.6250 167.334290 42.950851 8.496363 3.618581
15 | 14 0.6750 166.338120 41.954693 8.444273 3.566491
16 | 15 0.7250 165.393295 41.009853 8.390163 3.512382
17 | 16 0.7750 164.498749 40.115303 8.334126 3.456343
18 | 17 0.8250 163.653503 39.270042 8.276241 3.398460
19 | 18 0.8750 162.856628 38.473190 8.216595 3.338813
20 | 19 0.9250 162.107376 37.723934 8.155258 3.277476
21 | 20 0.9750 161.404938 37.021484 8.092304 3.214522
22 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/filter_exposedvegp.m:
--------------------------------------------------------------------------------
1 | function [vegetation] = filter_exposedvegp(vegetation)
2 | %this is a dummy function since we only have trees as patch so far!!!!! :)
3 | f = vegetation.mlcanopyinst.f;
4 | vegetation.mlcanopyinst.p=f;
5 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/ft.m:
--------------------------------------------------------------------------------
1 | %-----------------------------------------------------------------------
2 | function [pstr] = ft (vegetation, t, ha)
3 |
4 | % DESCRIPTION:
5 | % Photosynthesis temperature response
6 |
7 | % USES:
8 | % rgasc = vegetation.physcon.rgasc;
9 | % tfrz = vegetation.physcon.tfrz;
10 | % t = vegetation.mlcanopyinst.tleaf(p,ic,il);
11 | % ha = vegetation.leaf.kcha;
12 |
13 |
14 | % ha = vegetation.mlcanopyinst.ha; %dummy values for now
15 |
16 | % ARGUMENTS:
17 | % implicit none
18 | % real(r8) :: tl % Leaf temperature (K)
19 | % real(r8) :: ha % Activation energy (J/mol)
20 | %
21 | % LOCAL VARIABLES:
22 | % real(r8) :: ans % Temperature function value
23 | %---------------------------------------------------------------------
24 |
25 | pstr = exp(ha / (vegetation.physcon.rgasc * (vegetation.physcon.tfrz+25)) * (1 - (vegetation.physcon.tfrz+25) / t) );
26 |
27 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/fth.m:
--------------------------------------------------------------------------------
1 |
2 | %-----------------------------------------------------------------------
3 | function [ftv] = fth (vegetation, t, hd, se, c)
4 | %(tl, hd, se, c, clm_varcon)
5 |
6 | % DESCRIPTION:
7 | % Photosynthesis temperature inhibition
8 | % tl = vegetation.mlcanopyinst.t1; %dummy values for now
9 | % hd = vegetation.mlcanopyinst.hd; %dummy values for now
10 | % se = vegetation.mlcanopyinst.se; %dummy values for now
11 | % c = vegetation.mlcanopyinst.c; %dummy values for now
12 |
13 | % ARGUMENTS:
14 | % implicit none
15 | % real(r8) :: tl % Leaf temperature (K)
16 | % real(r8) :: hd % Deactivation energy (J/mol)
17 | % real(r8) :: se % Entropy term (J/mol/K)
18 | % real(r8) :: c % Scaling factor for high temperature inhibition (25 C = 1.0)
19 | %
20 | % %LOCAL VARIABLES:
21 | % real(r8) :: ans % Temperature function value
22 | %---------------------------------------------------------------------
23 |
24 | ftv = c ./ (1+ exp((-hd + se*t) ./ (vegetation.physcon.rgasc*t)));
25 |
26 |
27 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/fth25.m:
--------------------------------------------------------------------------------
1 | %-----------------------------------------------------------------------
2 | function [fth25F] = fth25(vegetation, hd, se)
3 | %
4 | % %DESCRIPTION:
5 | % Scaling factor for photosynthesis temperature inhibition
6 |
7 | % hd = vegetation.mlcanopyinst.hd; %dummy values for now
8 | % se = vegetation.mlcanopyinst.se; %dummy values for now
9 |
10 | % ARGUMENTS:
11 | % hd = 1; % Deactivation energy (J/mol)
12 | % se = 1; % Entropy term (J/mol/K)
13 |
14 | % LOCAL VARIABLES:
15 | %ans % Temperature function value
16 | %---------------------------------------------------------------------
17 |
18 | fth25F = 1. + exp((-hd + se .* (vegetation.physcon.tfrz+25)) ./ (vegetation.physcon.rgasc .* (vegetation.physcon.tfrz+25)));
19 |
20 | % vegetation.mlcanopyinst.fth25F = fth25F;
21 | end
22 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/fth25_g.m:
--------------------------------------------------------------------------------
1 | %-----------------------------------------------------------------------
2 | function [fth25F] = fth25_g(ground, hd, se)
3 | %
4 | % %DESCRIPTION:
5 | % Scaling factor for photosynthesis temperature inhibition
6 |
7 | % hd = ground.STATVAR.vegetation.mlcanopyinst.hd; %dummy values for now
8 | % se = ground.STATVAR.vegetation.mlcanopyinst.se; %dummy values for now
9 |
10 | % ARGUMENTS:
11 | % hd = 1; % Deactivation energy (J/mol)
12 | % se = 1; % Entropy term (J/mol/K)
13 |
14 | % LOCAL VARIABLES:
15 | %ans % Temperature function value
16 | %---------------------------------------------------------------------
17 |
18 | fth25F = 1. + exp((-hd + se .* (ground.STATVAR.vegetation.physcon.tfrz+25)) ./ (ground.STATVAR.vegetation.physcon.rgasc .* (ground.STATVAR.vegetation.physcon.tfrz+25)));
19 |
20 | % ground.STATVAR.vegetation.mlcanopyinst.fth25F = fth25F;
21 | end
22 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/get_F_lb.m:
--------------------------------------------------------------------------------
1 | function ground = get_heatFlux_lb(ground, forcing)
2 |
3 | ground.TEMP.F_lb = forcing.PARA.heatFlux_lb;
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/hybrid_root.m:
--------------------------------------------------------------------------------
1 |
2 | function [vegetation, root] = hybrid_root(func_name, vegetation, p, ic, il, xa, xb, tol) %, FORCING
3 |
4 | % Solve for the root of a function using the secant and Brent's methods given
5 | % initial estimates xa and xb. The root is updated until its accuracy is tol.
6 | % func is the name of the function to solve. The variable root is returned as
7 | % the root of the function. The function being evaluated has the definition statement:
8 | %
9 | % function [flux, fx] = func (physcon, atmos, leaf, flux, x)
10 | %
11 | % The function func is exaluated at x and the returned value is fx. It uses variables
12 | % in the physcon, atmos, leaf, and flux structures. These are passed in as
13 | % input arguments. It also calculates values for variables in the flux structure
14 | % so this must be returned in the function call as an output argument. The matlab
15 | % function feval evaluates func.
16 |
17 | % --- Evaluate func at xa and see if this is the root
18 |
19 | x0 = xa;
20 | [vegetation, f0] = feval(func_name, vegetation, p, ic, il, x0);
21 | if (f0 == 0.0)
22 | root = x0;
23 | return
24 | end
25 |
26 | % --- Evaluate func at xb and see if this is the root
27 |
28 | x1 = xb;
29 | [vegetation, f1] = feval(func_name, vegetation, p, ic, il, x1);
30 | if (f1 == 0)
31 | root = x1;
32 | return
33 | end
34 |
35 | % --- Order initial root estimates correctly
36 |
37 | if (f1 < f0)
38 | minx = x1;
39 | minf = f1;
40 | else
41 | minx = x0;
42 | minf = f0;
43 | end
44 |
45 | % --- Iterative root calculation. Use the secant method, with Brent's method as a backup
46 |
47 | itmax = 40;
48 | for iter = 1:itmax
49 | dx = -f1 * (x1 - x0) / (f1 - f0);
50 | x = x1 + dx;
51 |
52 | % Check if x is the root. If so, exit the iteration
53 |
54 | if (abs(dx) < tol)
55 | x0 = x;
56 | break
57 | end
58 |
59 | % Evaluate the function at x
60 |
61 | x0 = x1;
62 | f0 = f1;
63 | x1 = x;
64 | [vegetation, f1] = feval(func_name, vegetation, p, ic, il, x1);
65 | if (f1 < minf)
66 | minx = x1;
67 | minf = f1;
68 | end
69 |
70 | % If a root zone is found, use Brent's method for a robust backup strategy
71 | % and exit the iteration
72 |
73 | if (f1 * f0 < 0)
74 | [vegetation, x] = brent_root (func_name, vegetation, p, ic, il, x0, x1, tol);
75 | x0 = x;
76 | break
77 | end
78 |
79 | % In case of failing to converge within itmax iterations stop at the minimum function
80 |
81 | if (iter == itmax)
82 | [vegetation, f1] = feval(func_name, vegetation, p, ic, il, minx);
83 | x0 = minx;
84 | end
85 |
86 | end
87 |
88 | root = x0;
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/initialize_atmos.m:
--------------------------------------------------------------------------------
1 | function [ground] = initialize_atmos(ground)
2 |
3 | ground.STATVAR.vegetation.mlcanopyinst.numrad = 2; % Number of wavebands
4 | numrad = ground.STATVAR.vegetation.mlcanopyinst.numrad;
5 |
6 | ground.STATVAR.vegetation.atmos.swskyb = zeros(1,numrad);
7 | ground.STATVAR.vegetation.atmos.swskyd = zeros(1,numrad);
8 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/initialize_flux.m:
--------------------------------------------------------------------------------
1 | function [ground] = initialize_flux(ground)
2 |
3 | % nleaf = ground.STATVAR.vegetation.mlcanopyinst.nleaf;
4 | % ncan = ground.STATVAR.vegetation.mlcanopyinst.ncan;
5 | ground.STATVAR.vegetation.mlcanopyinst.numrad = 2; % Number of wavebands
6 | numrad = ground.STATVAR.vegetation.mlcanopyinst.numrad;
7 |
8 | % ground.STATVAR.vegetation.flux.albsoib = zeros(1,ground.STATVAR.vegetation.mlcanopyinst.nleaf);
9 | % ground.STATVAR.vegetation.flux.albsoid = zeros(1,ground.STATVAR.vegetation.mlcanopyinst.nleaf);
10 | ground.STATVAR.vegetation.flux.fracsun = zeros(1,ground.STATVAR.vegetation.mlcanopyinst.ncan);
11 | ground.STATVAR.vegetation.flux.fracsha = zeros(1,ground.STATVAR.vegetation.mlcanopyinst.ncan);
12 | ground.STATVAR.vegetation.flux.swsoi = zeros(1,2);
13 | ground.STATVAR.vegetation.flux.swveg = zeros(1,2);
14 | ground.STATVAR.vegetation.flux.swvegsun = zeros(1,2);
15 | ground.STATVAR.vegetation.flux.swvegsha = zeros(1,2);
16 | ground.STATVAR.vegetation.flux.swleaf = zeros(1,ground.STATVAR.vegetation.mlcanopyinst.ncan,ground.STATVAR.vegetation.mlcanopyinst.nleaf,numrad);
17 | ground.STATVAR.vegetation.flux.albcan = zeros(1,ground.STATVAR.vegetation.mlcanopyinst.nleaf);
18 | ground.STATVAR.vegetation.flux.apar = zeros(1,ground.STATVAR.vegetation.mlcanopyinst.ncan,ground.STATVAR.vegetation.mlcanopyinst.nleaf);
19 | ground.STATVAR.vegetation.flux.ir_source_sun = zeros(1);
20 | ground.STATVAR.vegetation.flux.ir_source_sha = zeros(1);
21 | ground.STATVAR.vegetation.flux.ir_source = zeros(1,ground.STATVAR.vegetation.mlcanopyinst.ncan,ground.STATVAR.vegetation.mlcanopyinst.nleaf);
22 | ground.STATVAR.vegetation.flux.irsoi = zeros(1);
23 | ground.STATVAR.vegetation.flux.irveg = zeros(1);
24 | ground.STATVAR.vegetation.flux.irup = zeros(1);
25 |
26 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/initialize_forcing.m:
--------------------------------------------------------------------------------
1 |
2 | function FORCING = initialize_forcing(i)
3 |
4 | load('CG3_CCLM_forcing_90_101.mat')
5 |
6 | %i = 22841;
7 | p = 1;
8 |
9 |
10 | FORCING.i =[];
11 | FORCING.i.Sin(p)=double(FORCING.data.Sin(i)); %(21522);
12 | FORCING.i.Lin(p)=double(FORCING.data.Lin(i)); %(21522);
13 | FORCING.i.rainfall(p)= double(FORCING.data.rainfall(i)); %(21522);
14 | FORCING.i.snowfall(p)= double(FORCING.data.snowfall(i)); %(21522);
15 | FORCING.i.q(p)=double(FORCING.data.q(i)); %(21522);
16 | FORCING.i.Tair(p)= double(FORCING.data.Tair(i)); %(21522);
17 | FORCING.i.wind(p)= double(FORCING.data.wind(i)); %(21522);
18 | FORCING.i.p(p)=double(FORCING.data.p(i)); %(21522);
19 | FORCING.i.t_span(p)=double(FORCING.data.t_span(i)); %(21522);
20 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/initialize_leaf.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/initialize_leaf.m
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/initialize_mlcanopyinst.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/initialize_mlcanopyinst.m
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/initialize_params.m:
--------------------------------------------------------------------------------
1 |
2 | function [ground] = initialize_params(ground)
3 |
4 | %clm_arguments structure/container
5 | ground.STATVAR.vegetation.params.numrad = 2; % Number of wavebands (visible, near-infrared)
6 | ground.STATVAR.vegetation.params.vis = 1; % Array index for visible waveband
7 | ground.STATVAR.vegetation.params.nir = 2; % Array index for near-infrared waveband
8 | ground.STATVAR.vegetation.params.sun = 1; % Array index for sunlit leaf
9 | ground.STATVAR.vegetation.params.sha = 2; % Array index for shaded leaf
10 | ground.STATVAR.vegetation.params.npts = 1; % Number of grid points to process
11 |
12 | ground.STATVAR.vegetation.params.gstyp = 2; %1; % Stomatal conductance: 0 = Medlyn model. 1 = Ball-Berry model. 2 = WUE optimization
13 |
14 | end
15 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/initialize_soil.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/initialize_soil.m
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/phi_c_monin_obukhov.m:
--------------------------------------------------------------------------------
1 | function [phi_c] = phi_c_monin_obukhov (x)
2 |
3 | % --- Evaluate the Monin-Obukhov phi function for scalars at x
4 |
5 | if (x < 0)
6 | phi_c = (1 - 16 * x)^(-0.5);
7 | else
8 | phi_c = 1 + 5 * x;
9 | end
10 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/phi_m_monin_obukhov.m:
--------------------------------------------------------------------------------
1 | function [phi_m] = phi_m_monin_obukhov (zeta)
2 |
3 | % --- Evaluate the Monin-Obukhov phi function for momentum at x
4 |
5 | if (zeta < 0)
6 | phi_m = (1 - 16 * zeta)^(-0.25);
7 | else
8 | phi_m = 1 + 5 * zeta;
9 | end
10 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/plots.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/plots.m
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/psi_c_monin_obukhov.m:
--------------------------------------------------------------------------------
1 | function [psi_c] = psi_c_monin_obukhov (x)
2 |
3 | % --- Evaluate the Monin-Obukhov psi function for scalars at x
4 |
5 | if (x < 0)
6 | y = (1 - 16 * x)^0.25;
7 | psi_c = 2 * log((1 + y^2)/2);
8 | else
9 | psi_c = -5 * x;
10 | end
11 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/psi_m_monin_obukhov.m:
--------------------------------------------------------------------------------
1 | function [psi_m] = psi_m_monin_obukhov (x)
2 |
3 | % --- Evaluate the Monin-Obukhov psi function for momentum at x
4 |
5 | if (x < 0)
6 | y = (1 - 16 * x)^0.25;
7 | psi_m = 2 * log((1 + y)/2) + log((1 + y^2)/2) - 2 * atan(y) + pi / 2;
8 | else
9 | psi_m = -5 * x;
10 | end
11 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/quadratic.m:
--------------------------------------------------------------------------------
1 | %Mathtools%-----------------------------------------------------------------------
2 | function [r1, r2] = quadratic(a, b, c) % (a, b, c, r1, r2)
3 |
4 | % DESCRIPTION:
5 | % Solve a quadratic equation for its two roots
6 |
7 | %ARGUMENTS:
8 | % a, b, c % Terms for quadratic equation
9 | % r1, r2 % Roots of quadratic equation
10 |
11 | %LOCAL VARIABLES:
12 | % q % Temporary term for quadratic solution
13 |
14 |
15 | % Whatever values given as a, b, c, right before the function is executed.
16 | % a = 1; % dummy values
17 | % b = 1; % dummy values
18 | % c = 1; % dummy values
19 |
20 |
21 | if (a == 0)
22 | fprintf("Quadratic solution error: a = ", a); %?
23 | % call endrun()
24 | end
25 |
26 | if (b >= 0 )
27 | q = -0.5 .* (b + sqrt(b.*b - 4 .*a.*c));
28 | else
29 | q = -0.5 .* (b - sqrt(b.*b - 4 .*a.*c));
30 | end
31 |
32 | r1 = q ./ a;
33 | if (q ~= 0)
34 | r2 = c ./ q;
35 | else
36 | r2 = 1.e36;
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/shell_001.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/shell_001.m
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/surface_energy_balance.m:
--------------------------------------------------------------------------------
1 | function ground = surface_energy_balance(ground, forcing)
2 |
3 |
4 | ground.STATVAR.Lout = (1-ground.PARA.epsilon) .* forcing.TEMP.Lin + ground.PARA.epsilon .* ground.CONST.sigma .* (ground.STATVAR.T(1)+ 273.15).^4;
5 | ground.STATVAR.Sout = ground.PARA.albedo .* forcing.TEMP.Sin;
6 | ground.STATVAR.Qh = Q_h(ground, forcing);
7 | ground.STATVAR.Qe = Q_eq(ground, forcing);
8 |
9 | ground.TEMP.F_ub = forcing.TEMP.Sin + forcing.TEMP.Lin - ground.STATVAR.Lout - ground.STATVAR.Sout - ground.STATVAR.Qh - ground.STATVAR.Qe;
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/test_leaf_ET_sebas.m:
--------------------------------------------------------------------------------
1 | leaf_ET=[];
2 | transp_flux_per_layer = [];
3 |
4 | for i=1:size(out.FORCING,2)
5 | frac_sun_shade = cat(3, out.VEGETATION{1,i}.STATVAR.vegetation.flux.fracsun, out.VEGETATION{1,i}.STATVAR.vegetation.flux.fracsha);
6 | let=out.VEGETATION{1,i}.STATVAR.vegetation.mlcanopyinst.trleaf .* frac_sun_shade;
7 | let=sum(let,3); %per m2 leaf per m2 ground
8 | let= let .* out.VEGETATION{1,i}.STATVAR.vegetation.canopy.dlai; %per m2 ground
9 | let_tot = sum(0.018e-3 .* let); %in m3/me water/sec
10 | tfpl = let_tot .* out.VEGETATION{1,i}.STATVAR.vegetation.mlcanopyinst.soil_et_loss;
11 | transp_flux_per_layer = [transp_flux_per_layer; tfpl];
12 | leaf_ET=[leaf_ET; let];
13 | end
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/untitled.fig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoGrid/CryoGridCommunity_source/e82b5a4ec8bf6fab87670bbaf626e87f58b51c21/source/TIER_2_full_classes/VEGETATION/@VEGETATION_ml_canopy/private/untitled.fig
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/IA_ml_canopy_GROUND.m:
--------------------------------------------------------------------------------
1 | classdef IA_ml_canopy_GROUND < IA_BASE
2 |
3 |
4 | properties
5 | GROUND
6 | VEGETATION
7 | end
8 |
9 | methods
10 | function get_transpiration(ia_vegetation_ground)
11 |
12 | ground = ia_vegetation_surface.SURFACE;
13 | vegetation = ia_vegetation_surface.VEGATION;
14 |
15 | vegetation.STATVAR.vegetation.soilvar.transp_per_layer = (0.0181528 .* vegetation.STATVAR.vegetation.soilvar.transp_per_layer)./1000;
16 |
17 |
18 | ground.TEMP.d_water(1,1) = ground.TEMP.d_water(1,1) - vegetation.STATVAR.vegetation.soilvar.transp_per_layer(1,1) .* ground.STATVAR.area(1,1);
19 | ground.TEMP.d_water(2:3,1) = ground.TEMP.d_water(2:3,1) - vegetation.STATVAR.vegetation.soilvar.transp_per_layer(2,1)/2 .* ground.STATVAR.area(2:3,1);
20 | ground.TEMP.d_water(4:9,1) = ground.TEMP.d_water(4:9,1) - vegetation.STATVAR.vegetation.soilvar.transp_per_layer(3,1)/6 .* ground.STATVAR.area(4:9,1);
21 |
22 | end
23 |
24 | function get_evaporation(ia_vegetation_ground)
25 |
26 | ground = ia_vegetation_surface.SURFACE;
27 | vegetation = ia_vegetation_surface.VEGATION;
28 |
29 | vegetation.STATVAR.vegetation.mlcanopyinst.etsoi = (0.0181528 .* vegetation.STATVAR.vegetation.mlcanopyinst.etsoi)./1000;
30 |
31 | ground.TEMP.d_water(1,1) = ground.TEMP.d_water(1,1) - vegetation.STATVAR.vegetation.mlcanopyinst.etsoi .* ground.STATVAR.area(1,1);
32 |
33 | end
34 | end
35 | end
36 |
37 |
--------------------------------------------------------------------------------
/source/TIER_2_full_classes/VEGETATION/IA_ml_canopy_SURFACE.m:
--------------------------------------------------------------------------------
1 | classdef IA_ml_canopy_SURFACE < IA_BASE
2 |
3 |
4 | properties
5 | SURFACE %points to the SURFACE class (GROUND or SNOW)
6 | VEGATION
7 | end
8 |
9 | methods
10 |
11 | function get_boundary_condition_u_vegetation_GROUND_surface(ia_vegetation_surface)
12 | ground = ia_vegetation_surface.SURFACE;
13 | vegetation = ia_vegetation_surface.VEGATION;
14 | forcing = vegetation.ForcingV;
15 |
16 | % fluxes from ground and snow overwritten by fluxes from vegetation module
17 | ground.STATVAR.Qh = vegetation.STATVAR.vegetation.mlcanopyinst.shsoi;
18 | ground.STATVAR.Qe = vegetation.STATVAR.vegetation.mlcanopyinst.lhsoi;
19 | ground.TEMP.F_ub = vegetation.STATVAR.vegetation.mlcanopyinst.gsoi .* ground.STATVAR.area(1,1);
20 | ground.TEMP.d_energy(1,1) = ground.TEMP.d_energy(1,1) + ground.TEMP.F_ub; %BE CAREFUL, THIS MAY DOUBLE-COUNT THE GROUND HEAT FLUX!
21 |
22 |
23 | vegetation.STATVAR.vegetation.soilvar.t_top_surfacecell = ground.STATVAR.T(1) + 273.15;
24 | vegetation.STATVAR.vegetation.soilvar.dz_topsurfacecell = ground.STATVAR.layerThick(1);
25 | vegetation.STATVAR.vegetation.soilvar.thk_topsurfacecell = ground.STATVAR.thermCond(1);
26 |
27 |
28 |
29 | end
30 |
31 | function get_boundary_condition_u_vegetation_SNOW_surface(ia_vegetation_surface)
32 | ground = ia_vegetation_surface.SURFACE;
33 | vegetation = ia_vegetation_surface.VEGATION;
34 | forcing = vegetation.ForcingV;
35 |
36 |
37 |
38 |
39 | end
40 |
41 | end
42 | end
43 |
44 |
--------------------------------------------------------------------------------