igm-model 2.2.2__tar.gz → 3.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {igm_model-2.2.2/igm_model.egg-info → igm_model-3.0.0}/PKG-INFO +16 -3
- {igm_model-2.2.2 → igm_model-3.0.0}/README.md +1 -1
- igm_model-3.0.0/igm/__init__.py +8 -0
- igm_model-3.0.0/igm/common/__init__.py +16 -0
- igm_model-3.0.0/igm/common/core/__init__.py +1 -0
- igm_model-3.0.0/igm/common/core/src.py +20 -0
- igm_model-3.0.0/igm/common/runner/__init__.py +8 -0
- igm_model-3.0.0/igm/common/runner/configuration/__init__.py +1 -0
- igm_model-3.0.0/igm/common/runner/configuration/loader.py +44 -0
- igm_model-3.0.0/igm/common/runner/configuration/utils.py +86 -0
- igm_model-3.0.0/igm/common/runner/modules/__init__.py +1 -0
- igm_model-3.0.0/igm/common/runner/modules/loader.py +182 -0
- igm_model-3.0.0/igm/common/runner/modules/src.py +61 -0
- igm_model-3.0.0/igm/common/runner/modules/utils.py +34 -0
- igm_model-3.0.0/igm/common/runner/modules/validator.py +9 -0
- igm_model-3.0.0/igm/common/utilities/__init__.py +6 -0
- igm_model-3.0.0/igm/common/utilities/misc.py +56 -0
- igm_model-3.0.0/igm/common/utilities/printers.py +95 -0
- igm_model-3.0.0/igm/common/utilities/visualizers.py +95 -0
- {igm_model-2.2.2/tests/test_iceflow → igm_model-3.0.0/igm/conf}/__init__.py +0 -0
- igm_model-3.0.0/igm/igm_run.py +120 -0
- igm_model-3.0.0/igm/inputs/__init__.py +6 -0
- igm_model-3.0.0/igm/inputs/complete_data.py +38 -0
- {igm_model-2.2.2/igm/modules/preproc/include_icemask → igm_model-3.0.0/igm/inputs}/include_icemask.py +3 -29
- igm_model-3.0.0/igm/inputs/load_ncdf.py +97 -0
- igm_model-3.0.0/igm/inputs/load_tif.py +73 -0
- igm_model-3.0.0/igm/inputs/local.py +117 -0
- igm_model-3.0.0/igm/inputs/oggm_shop/__init__.py +1 -0
- igm_model-3.0.0/igm/inputs/oggm_shop/arrange_data.py +87 -0
- igm_model-3.0.0/igm/inputs/oggm_shop/make_input_file.py +50 -0
- igm_model-3.0.0/igm/inputs/oggm_shop/masks_subentities.py +60 -0
- igm_model-3.0.0/igm/inputs/oggm_shop/oggm_shop.py +56 -0
- igm_model-3.0.0/igm/inputs/oggm_shop/oggm_util.py +167 -0
- igm_model-3.0.0/igm/inputs/oggm_shop/open_gridded_data.py +39 -0
- igm_model-3.0.0/igm/inputs/oggm_shop/read_glathida.py +124 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/igm/instructed_oggm.py +8 -20
- igm_model-3.0.0/igm/outputs/__init__.py +8 -0
- igm_model-3.0.0/igm/outputs/local.py +201 -0
- igm_model-3.0.0/igm/outputs/plot2d.py +93 -0
- {igm_model-2.2.2/igm/modules/postproc/write_ncdf → igm_model-3.0.0/igm/outputs}/write_ncdf.py +29 -70
- {igm_model-2.2.2/igm/modules/postproc/write_tif → igm_model-3.0.0/igm/outputs}/write_tif.py +4 -22
- {igm_model-2.2.2/igm/modules/postproc/write_ts → igm_model-3.0.0/igm/outputs}/write_ts.py +5 -18
- igm_model-3.0.0/igm/outputs/write_vtp.py +119 -0
- igm_model-3.0.0/igm/processes/__init__.py +4 -0
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/avalanche/__init__.py +0 -1
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/avalanche/avalanche.py +43 -41
- igm_model-3.0.0/igm/processes/clim_glacialindex/__init__.py +5 -0
- igm_model-3.0.0/igm/processes/clim_glacialindex/clim_glacialindex.py +267 -0
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/clim_oggm/__init__.py +0 -1
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/clim_oggm/clim_oggm.py +44 -87
- igm_model-3.0.0/igm/processes/damage/__init__.py +5 -0
- igm_model-3.0.0/igm/processes/damage/damage.py +86 -0
- igm_model-3.0.0/igm/processes/data_assimilation/__init__.py +5 -0
- igm_model-3.0.0/igm/processes/data_assimilation/data_assimilation.py +75 -0
- igm_model-3.0.0/igm/processes/data_assimilation/utils.py +116 -0
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/enthalpy/__init__.py +0 -1
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/enthalpy/enthalpy.py +193 -307
- igm_model-3.0.0/igm/processes/flow_accumulation/__init__.py +5 -0
- igm_model-3.0.0/igm/processes/flow_accumulation/flow_accumulation.py +82 -0
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/gflex/__init__.py +0 -1
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/gflex/gflex.py +19 -57
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/glerosion/__init__.py +0 -1
- igm_model-3.0.0/igm/processes/glerosion/glerosion.py +43 -0
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/iceflow/__init__.py +0 -1
- igm_model-3.0.0/igm/processes/iceflow/energy/__init__.py +4 -0
- igm_model-3.0.0/igm/processes/iceflow/energy/cost_floating.py +111 -0
- igm_model-3.0.0/igm/processes/iceflow/energy/cost_gravity.py +70 -0
- igm_model-3.0.0/igm/processes/iceflow/energy/cost_shear.py +180 -0
- igm_model-3.0.0/igm/processes/iceflow/energy/cost_sliding_weertman.py +43 -0
- igm_model-3.0.0/igm/processes/iceflow/energy/energy.py +30 -0
- igm_model-3.0.0/igm/processes/iceflow/energy/sliding_laws/__init__.py +2 -0
- igm_model-3.0.0/igm/processes/iceflow/energy/sliding_laws/sliding_law.py +32 -0
- igm_model-3.0.0/igm/processes/iceflow/energy/sliding_laws/weertman.py +34 -0
- igm_model-3.0.0/igm/processes/iceflow/energy/utils.py +100 -0
- igm_model-3.0.0/igm/processes/iceflow/iceflow.py +122 -0
- igm_model-3.0.0/igm/processes/iceflow/utils.py +204 -0
- igm_model-3.0.0/igm/processes/iceflow/vert_disc.py +47 -0
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/particles/__init__.py +0 -1
- igm_model-3.0.0/igm/processes/particles/particles.py +76 -0
- igm_model-3.0.0/igm/processes/particles/remove_particles.py +27 -0
- igm_model-3.0.0/igm/processes/particles/seeding_particles.py +129 -0
- igm_model-3.0.0/igm/processes/particles/update_particles.py +114 -0
- igm_model-3.0.0/igm/processes/particles/utils.py +61 -0
- igm_model-3.0.0/igm/processes/particles/utils_cuda.py +37 -0
- igm_model-3.0.0/igm/processes/particles/utils_cupy.py +183 -0
- igm_model-3.0.0/igm/processes/particles/utils_interp.py +103 -0
- igm_model-3.0.0/igm/processes/particles/utils_tf.py +20 -0
- igm_model-3.0.0/igm/processes/particles/write_particle_cudf.py +114 -0
- igm_model-3.0.0/igm/processes/particles/write_particle_numpy.py +73 -0
- igm_model-3.0.0/igm/processes/pretraining/__init__.py +5 -0
- {igm_model-2.2.2/igm/modules/preproc → igm_model-3.0.0/igm/processes}/pretraining/pretraining.py +152 -203
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/read_output/__init__.py +0 -1
- igm_model-3.0.0/igm/processes/read_output/read_output.py +71 -0
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/rockflow/__init__.py +0 -1
- igm_model-3.0.0/igm/processes/rockflow/rockflow.py +39 -0
- igm_model-3.0.0/igm/processes/smb_accpdd/__init__.py +5 -0
- igm_model-3.0.0/igm/processes/smb_accpdd/smb_accpdd.py +142 -0
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/smb_oggm/__init__.py +0 -1
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/smb_oggm/smb_oggm.py +23 -50
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/smb_simple/__init__.py +0 -1
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/smb_simple/smb_simple.py +11 -38
- igm_model-3.0.0/igm/processes/stress/__init__.py +5 -0
- igm_model-3.0.0/igm/processes/stress/stress.py +134 -0
- igm_model-3.0.0/igm/processes/texture/__init__.py +1 -0
- {igm_model-2.2.2/igm/modules/postproc → igm_model-3.0.0/igm/processes}/texture/pix2pixhd.py +8 -5
- {igm_model-2.2.2/igm/modules/postproc → igm_model-3.0.0/igm/processes}/texture/preparer.py +3 -3
- {igm_model-2.2.2/igm/modules/postproc → igm_model-3.0.0/igm/processes}/texture/texture.py +61 -70
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/thk/__init__.py +0 -1
- igm_model-3.0.0/igm/processes/thk/thk.py +58 -0
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/time/__init__.py +0 -1
- igm_model-3.0.0/igm/processes/time/time.py +68 -0
- {igm_model-2.2.2/igm/modules/process → igm_model-3.0.0/igm/processes}/vert_flow/__init__.py +0 -1
- igm_model-3.0.0/igm/processes/vert_flow/vert_flow.py +59 -0
- igm_model-3.0.0/igm/processes/vert_flow/vert_flow_legendre.py +31 -0
- igm_model-2.2.2/igm/modules/process/vert_flow/vert_flow.py → igm_model-3.0.0/igm/processes/vert_flow/vert_flow_v1.py +29 -61
- igm_model-3.0.0/igm/processes/vert_flow/vert_flow_v2.py +236 -0
- {igm_model-2.2.2 → igm_model-3.0.0/igm_model.egg-info}/PKG-INFO +16 -3
- igm_model-3.0.0/igm_model.egg-info/SOURCES.txt +151 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/igm_model.egg-info/entry_points.txt +0 -1
- {igm_model-2.2.2 → igm_model-3.0.0}/igm_model.egg-info/requires.txt +3 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/setup.py +5 -2
- igm_model-3.0.0/tests/test_data_assimilation/__init__.py +2 -0
- igm_model-3.0.0/tests/test_data_assimilation/test_data_assimilation.py +7 -0
- igm_model-3.0.0/tests/test_full_glacier_evolution_oggm_shop/test_full_glacier_evolution_oggm_shop.py +7 -0
- {igm_model-2.2.2/tests/test_params → igm_model-3.0.0/tests/test_iceflow}/__init__.py +0 -0
- igm_model-3.0.0/tests/test_iceflow/test_iceflow.py +24 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_load_ncdf/make_fake_ncdf.py +1 -1
- igm_model-3.0.0/tests/test_load_ncdf/test_load_ncdf.py +31 -0
- {igm_model-2.2.2/tests/test_vert_flow → igm_model-3.0.0/tests/test_params}/__init__.py +0 -0
- igm_model-3.0.0/tests/test_vert_flow/__init__.py +0 -0
- igm_model-3.0.0/tests/test_vert_flow/test_vert_flow.py +29 -0
- igm_model-2.2.2/igm/__init__.py +0 -29
- igm_model-2.2.2/igm/common.py +0 -453
- igm_model-2.2.2/igm/emulators/f15_cfsflow_GJ_22_a/100/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/f15_cfsflow_GJ_22_a/100/fieldout.dat +0 -6
- igm_model-2.2.2/igm/emulators/f15_cfsflow_GJ_22_a/100/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/f15_cfsflow_GJ_22_a/200/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/f15_cfsflow_GJ_22_a/200/fieldout.dat +0 -6
- igm_model-2.2.2/igm/emulators/f15_cfsflow_GJ_22_a/200/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/f15_cfsflow_GJ_22_a/50/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/f15_cfsflow_GJ_22_a/50/fieldout.dat +0 -6
- igm_model-2.2.2/igm/emulators/f15_cfsflow_GJ_22_a/50/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/f15_cfsflow_GJ_22_a/README.md +0 -26
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_16_3_1/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_16_3_1/fieldout.dat +0 -2
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_16_3_1/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_2_0/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_2_0/fieldout.dat +0 -2
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_2_0/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_2_1/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_2_1/fieldout.dat +0 -2
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_2_1/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_3_0/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_3_0/fieldout.dat +0 -2
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_3_0/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_3_1/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_3_1/fieldout.dat +0 -2
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_16_32_3_1/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_16_2_1/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_16_2_1/fieldout.dat +0 -2
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_16_2_1/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_16_3_1/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_16_3_1/fieldout.dat +0 -2
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_16_3_1/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_32_2_0/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_32_2_0/fieldout.dat +0 -2
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_32_2_0/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_32_2_1/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_32_2_1/fieldout.dat +0 -2
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_cnn_8_32_2_1/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_unet_16_32_2_1/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_unet_16_32_2_1/fieldout.dat +0 -2
- igm_model-2.2.2/igm/emulators/pinnbp_10_4_unet_16_32_2_1/model.h5 +0 -0
- igm_model-2.2.2/igm/emulators/pinnbp_30_4_cnn_12_32_3_1/fieldin.dat +0 -5
- igm_model-2.2.2/igm/emulators/pinnbp_30_4_cnn_12_32_3_1/fieldout.dat +0 -2
- igm_model-2.2.2/igm/emulators/pinnbp_30_4_cnn_12_32_3_1/model.h5 +0 -0
- igm_model-2.2.2/igm/igm_help.py +0 -30
- igm_model-2.2.2/igm/igm_run.py +0 -54
- igm_model-2.2.2/igm/modules/__init__.py +0 -10
- igm_model-2.2.2/igm/modules/postproc/__init__.py +0 -5
- igm_model-2.2.2/igm/modules/postproc/anim_mayavi/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/postproc/anim_mayavi/anim_mayavi.py +0 -96
- igm_model-2.2.2/igm/modules/postproc/anim_plotly/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/postproc/anim_plotly/anim_plotly.py +0 -350
- igm_model-2.2.2/igm/modules/postproc/anim_video/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/postproc/anim_video/anim_video.py +0 -66
- igm_model-2.2.2/igm/modules/postproc/plot2d/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/postproc/plot2d/plot2d.py +0 -138
- igm_model-2.2.2/igm/modules/postproc/print_comp/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/postproc/print_comp/print_comp.py +0 -176
- igm_model-2.2.2/igm/modules/postproc/print_info/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/postproc/print_info/print_info.py +0 -40
- igm_model-2.2.2/igm/modules/postproc/texture/__init__.py +0 -1
- igm_model-2.2.2/igm/modules/postproc/write_ncdf/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/postproc/write_particles/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/postproc/write_particles/write_particles.py +0 -96
- igm_model-2.2.2/igm/modules/postproc/write_tif/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/postproc/write_ts/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/preproc/__init__.py +0 -24
- igm_model-2.2.2/igm/modules/preproc/include_icemask/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/preproc/infersmb/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/preproc/infersmb/infersmb.py +0 -53
- igm_model-2.2.2/igm/modules/preproc/load_ncdf/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/preproc/load_ncdf/load_ncdf.py +0 -154
- igm_model-2.2.2/igm/modules/preproc/load_tif/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/preproc/load_tif/load_tif.py +0 -125
- igm_model-2.2.2/igm/modules/preproc/oggm_shop/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/preproc/oggm_shop/oggm_shop.py +0 -622
- igm_model-2.2.2/igm/modules/preproc/optimize/__init__.py +0 -8
- igm_model-2.2.2/igm/modules/preproc/optimize/optimize.py +0 -1759
- igm_model-2.2.2/igm/modules/preproc/optimize_v1/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/preproc/optimize_v1/optimize_v1.py +0 -1140
- igm_model-2.2.2/igm/modules/preproc/pretraining/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/process/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/process/flow_dt_thk/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/process/flow_dt_thk/flow_dt_thk.py +0 -32
- igm_model-2.2.2/igm/modules/process/glerosion/glerosion.py +0 -68
- igm_model-2.2.2/igm/modules/process/iceflow/iceflow.py +0 -1493
- igm_model-2.2.2/igm/modules/process/iceflow_v1/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/process/iceflow_v1/iceflow_v1.py +0 -192
- igm_model-2.2.2/igm/modules/process/particles/particles.py +0 -279
- igm_model-2.2.2/igm/modules/process/particles_v1/__init__.py +0 -6
- igm_model-2.2.2/igm/modules/process/particles_v1/particles_v1.py +0 -266
- igm_model-2.2.2/igm/modules/process/read_output/read_output.py +0 -99
- igm_model-2.2.2/igm/modules/process/rockflow/rockflow.py +0 -48
- igm_model-2.2.2/igm/modules/process/thk/thk.py +0 -79
- igm_model-2.2.2/igm/modules/process/time/time.py +0 -107
- igm_model-2.2.2/igm/modules/utils.py +0 -403
- igm_model-2.2.2/igm_model.egg-info/SOURCES.txt +0 -167
- igm_model-2.2.2/tests/test_full_glacier_evolution_oggm_shop/test_full_glacier_evolution_oggm_shop.py +0 -44
- igm_model-2.2.2/tests/test_full_glacier_evolution_synthetic/__init__.py +0 -2
- igm_model-2.2.2/tests/test_full_glacier_evolution_synthetic/make_synthetic.py +0 -42
- igm_model-2.2.2/tests/test_full_glacier_evolution_synthetic/test_full_glacier_evolution_synthetic.py +0 -43
- igm_model-2.2.2/tests/test_iceflow/test_iceflow.py +0 -39
- igm_model-2.2.2/tests/test_load_ncdf/test_load_ncdf.py +0 -39
- igm_model-2.2.2/tests/test_optimize/__init__.py +0 -2
- igm_model-2.2.2/tests/test_optimize/test_optimize.py +0 -41
- igm_model-2.2.2/tests/test_vert_flow/test_vert_flow.py +0 -37
- {igm_model-2.2.2 → igm_model-3.0.0}/LICENSE +0 -0
- {igm_model-2.2.2/igm/modules/postproc → igm_model-3.0.0/igm/processes}/texture/constants.py +0 -0
- {igm_model-2.2.2/igm/modules/postproc → igm_model-3.0.0/igm/processes}/texture/emulator.py +0 -0
- {igm_model-2.2.2/igm/modules/postproc → igm_model-3.0.0/igm/processes}/texture/exporter.py +0 -0
- {igm_model-2.2.2/igm/modules/postproc → igm_model-3.0.0/igm/processes}/texture/image_data.py +0 -0
- {igm_model-2.2.2/igm/modules/postproc → igm_model-3.0.0/igm/processes}/texture/normalizer.py +0 -0
- {igm_model-2.2.2/igm/modules/postproc → igm_model-3.0.0/igm/processes}/texture/utils.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/igm_model.egg-info/dependency_links.txt +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/igm_model.egg-info/top_level.txt +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/setup.cfg +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/__init__.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_full_glacier_evolution_oggm_shop/__init__.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_load_ncdf/__init__.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_modules/__init__.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_modules/invalid_custom_module_folder/__init__.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_modules/invalid_custom_module_folder/invalid_custom_module.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_modules/missing_function_custom_module.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_modules/test_loading_modules.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_modules/valid_custom_module.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_modules/valid_custom_module_folder/__init__.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_modules/valid_custom_module_folder/valid_custom_module.py +0 -0
- {igm_model-2.2.2 → igm_model-3.0.0}/tests/test_params/test_params.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: igm-model
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: IGM - a glacier evolution model
|
|
5
5
|
Home-page: https://github.com/jouvetg/igm
|
|
6
6
|
Author: Guillaume Jouvet
|
|
@@ -21,6 +21,19 @@ Requires-Dist: oggm
|
|
|
21
21
|
Requires-Dist: salem
|
|
22
22
|
Requires-Dist: pyyaml
|
|
23
23
|
Requires-Dist: importlib_resources
|
|
24
|
+
Requires-Dist: tqdm
|
|
25
|
+
Requires-Dist: hydra-core
|
|
26
|
+
Requires-Dist: omegaconf
|
|
27
|
+
Dynamic: author
|
|
28
|
+
Dynamic: author-email
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: description-content-type
|
|
31
|
+
Dynamic: home-page
|
|
32
|
+
Dynamic: license
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
Dynamic: requires-dist
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
Dynamic: summary
|
|
24
37
|
|
|
25
38
|
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
26
39
|
### <h1 align="center" id="title">The Instructed Glacier Model (IGM) </h1>
|
|
@@ -44,7 +57,7 @@ The Instructed Glacier Model (IGM) is an **open-source Python package**, which p
|
|
|
44
57
|
|
|
45
58
|
# Documentation
|
|
46
59
|
|
|
47
|
-
Start with the 10-min [video tutorial](https://vimeo.com/884003820). Then, all the documentation can be found on the dedicated [wiki](https://github.com/jouvetg/igm/wiki) and the the in-progress and open-to-contributions [technical paper](https://github.com/jouvetg/igm-paper/paper.pdf).
|
|
60
|
+
Start with the 10-min [video tutorial](https://vimeo.com/884003820). Then, all the documentation can be found on the dedicated [wiki](https://github.com/jouvetg/igm/wiki) and the the in-progress and open-to-contributions [technical paper](https://github.com/jouvetg/igm-paper/blob/main/paper.pdf).
|
|
48
61
|
|
|
49
62
|
# Discord channel
|
|
50
63
|
|
|
@@ -20,7 +20,7 @@ The Instructed Glacier Model (IGM) is an **open-source Python package**, which p
|
|
|
20
20
|
|
|
21
21
|
# Documentation
|
|
22
22
|
|
|
23
|
-
Start with the 10-min [video tutorial](https://vimeo.com/884003820). Then, all the documentation can be found on the dedicated [wiki](https://github.com/jouvetg/igm/wiki) and the the in-progress and open-to-contributions [technical paper](https://github.com/jouvetg/igm-paper/paper.pdf).
|
|
23
|
+
Start with the 10-min [video tutorial](https://vimeo.com/884003820). Then, all the documentation can be found on the dedicated [wiki](https://github.com/jouvetg/igm/wiki) and the the in-progress and open-to-contributions [technical paper](https://github.com/jouvetg/igm-paper/blob/main/paper.pdf).
|
|
24
24
|
|
|
25
25
|
# Discord channel
|
|
26
26
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from .core import State
|
|
2
|
+
|
|
3
|
+
from .runner import (
|
|
4
|
+
initialize_modules,
|
|
5
|
+
update_modules,
|
|
6
|
+
finalize_modules,
|
|
7
|
+
setup_igm_modules,
|
|
8
|
+
check_incompatilities_in_parameters_file,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
from .utilities import (
|
|
12
|
+
add_logger,
|
|
13
|
+
download_unzip_and_store,
|
|
14
|
+
print_comp,
|
|
15
|
+
print_gpu_info,
|
|
16
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .src import State, IGM_DESCRIPTION
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
IGM_DESCRIPTION = r"""
|
|
2
|
+
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
|
3
|
+
│ Welcome to IGM, a modular, open-source, fast, and user-friendly glacier evolution model! │
|
|
4
|
+
│ │
|
|
5
|
+
│ │
|
|
6
|
+
│ __/\\\\\\\\\\\_____/\\\\\\\\\\\\__/\\\\____________/\\\\_ │
|
|
7
|
+
│ _\/////\\\///____/\\\//////////__\/\\\\\\________/\\\\\\_ │
|
|
8
|
+
│ _____\/\\\______/\\\_____________\/\\\//\\\____/\\\//\\\_ │
|
|
9
|
+
│ _____\/\\\_____\/\\\____/\\\\\\\_\/\\\\///\\\/\\\/_\/\\\_ │
|
|
10
|
+
│ _____\/\\\_____\/\\\___\/////\\\_\/\\\__\///\\\/___\/\\\_ │
|
|
11
|
+
│ _____\/\\\_____\/\\\_______\/\\\_\/\\\____\///_____\/\\\_ │
|
|
12
|
+
│ _____\/\\\_____\/\\\_______\/\\\_\/\\\_____________\/\\\_ │
|
|
13
|
+
│ __/\\\\\\\\\\\_\//\\\\\\\\\\\\/__\/\\\_____________\/\\\_ │
|
|
14
|
+
│ _\///////////___\////////////____\///______________\///__ │
|
|
15
|
+
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class State:
|
|
20
|
+
pass
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .utils import check_incompatilities_in_parameters_file
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import os, yaml
|
|
2
|
+
from omegaconf import OmegaConf
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def load_yaml_as_cfg(yaml_filename):
|
|
6
|
+
from .utils import DictToObj
|
|
7
|
+
|
|
8
|
+
script_dir = os.path.dirname(
|
|
9
|
+
os.path.abspath(__file__)
|
|
10
|
+
) # Get the script's directory
|
|
11
|
+
yaml_path = os.path.join(script_dir, yaml_filename) # Build the full path
|
|
12
|
+
|
|
13
|
+
with open(yaml_path, "r") as file:
|
|
14
|
+
yaml_dict = yaml.safe_load(file) # Load as dict
|
|
15
|
+
|
|
16
|
+
return DictToObj(yaml_dict) # Convert to object
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def load_yaml_recursive(base_dir):
|
|
20
|
+
config = {}
|
|
21
|
+
for root, _, files in os.walk(base_dir):
|
|
22
|
+
for file in files:
|
|
23
|
+
if file.endswith(".yaml") or file.endswith(".yml"):
|
|
24
|
+
full_path = os.path.join(root, file)
|
|
25
|
+
relative_path = os.path.relpath(full_path, base_dir)
|
|
26
|
+
keys = (
|
|
27
|
+
relative_path.replace(".yaml", "").replace(".yml", "").split(os.sep)
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Load the YAML file
|
|
31
|
+
yaml_conf = OmegaConf.load(full_path)
|
|
32
|
+
|
|
33
|
+
# Nest it in the config dictionary
|
|
34
|
+
sub_conf = config
|
|
35
|
+
for key in keys[:-1]:
|
|
36
|
+
sub_conf = sub_conf.setdefault(key, {})
|
|
37
|
+
if keys[-1] in yaml_conf:
|
|
38
|
+
sub_conf[keys[-1]] = OmegaConf.merge(
|
|
39
|
+
sub_conf.get(keys[-1], {}), yaml_conf[keys[-1]]
|
|
40
|
+
)
|
|
41
|
+
else:
|
|
42
|
+
sub_conf[keys[-1]] = yaml_conf
|
|
43
|
+
|
|
44
|
+
return OmegaConf.create(config)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import igm
|
|
3
|
+
from omegaconf import OmegaConf
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from .loader import load_yaml_recursive
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class EmptyClass:
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class DictToObj:
|
|
14
|
+
"""Recursively convert a dictionary to an object with attribute-style access."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, dictionary):
|
|
17
|
+
for key, value in dictionary.items():
|
|
18
|
+
if isinstance(value, dict):
|
|
19
|
+
setattr(self, key, DictToObj(value))
|
|
20
|
+
else:
|
|
21
|
+
setattr(self, key, value)
|
|
22
|
+
|
|
23
|
+
def __getitem__(self, key):
|
|
24
|
+
return getattr(self, key) # Allow dictionary-like access
|
|
25
|
+
|
|
26
|
+
def __repr__(self):
|
|
27
|
+
return str(self.__dict__)
|
|
28
|
+
|
|
29
|
+
def to_dict(self):
|
|
30
|
+
"""Convert back to a dictionary."""
|
|
31
|
+
return {
|
|
32
|
+
key: value.to_dict() if isinstance(value, DictToObj) else value
|
|
33
|
+
for key, value in self.__dict__.items()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def check_incompatilities_in_parameters_file(cfg, path):
|
|
38
|
+
|
|
39
|
+
from difflib import get_close_matches
|
|
40
|
+
|
|
41
|
+
def flatten_dict(d, parent_key="", sep="."):
|
|
42
|
+
def recurse(obj, prefix):
|
|
43
|
+
if isinstance(obj, dict):
|
|
44
|
+
for k, v in obj.items():
|
|
45
|
+
yield from recurse(v, f"{prefix}{sep}{k}" if prefix else k)
|
|
46
|
+
elif isinstance(obj, list):
|
|
47
|
+
for i, item in enumerate(obj):
|
|
48
|
+
yield from recurse(item, f"{prefix}[{i}]")
|
|
49
|
+
else:
|
|
50
|
+
yield (prefix, obj)
|
|
51
|
+
|
|
52
|
+
return dict(recurse(d, parent_key))
|
|
53
|
+
|
|
54
|
+
def compare_configs(cfg, cfgo, path="", excluded_keys=["cwd", "config"]):
|
|
55
|
+
for key in cfg:
|
|
56
|
+
full_path = f"{path}.{key}" if path else key
|
|
57
|
+
if key not in excluded_keys:
|
|
58
|
+
if key not in cfgo:
|
|
59
|
+
# Get possible matches for the missing key
|
|
60
|
+
posskeys = flatten_dict(
|
|
61
|
+
OmegaConf.to_container(cfgo, resolve=False)
|
|
62
|
+
).keys()
|
|
63
|
+
suggestions = get_close_matches(key, posskeys, n=5, cutoff=0.2)
|
|
64
|
+
suggestions = [path + "." + s for s in suggestions]
|
|
65
|
+
suggestion_msg = (
|
|
66
|
+
f" Did you mean '{suggestions}'?" if suggestions else ""
|
|
67
|
+
)
|
|
68
|
+
raise ValueError(
|
|
69
|
+
f"Parameter '{full_path}' does not exist.\n {suggestion_msg}"
|
|
70
|
+
)
|
|
71
|
+
if OmegaConf.is_dict(cfg[key]):
|
|
72
|
+
if not OmegaConf.is_dict(cfgo[key]):
|
|
73
|
+
raise ValueError(
|
|
74
|
+
f"Configuration mismatch at '{full_path}': expected a dictionary-like config."
|
|
75
|
+
)
|
|
76
|
+
compare_configs(cfg[key], cfgo[key], full_path)
|
|
77
|
+
|
|
78
|
+
############################
|
|
79
|
+
|
|
80
|
+
cfgo = load_yaml_recursive(os.path.join(igm.__path__[0], "conf"))
|
|
81
|
+
|
|
82
|
+
addo = load_yaml_recursive(os.path.join(path, "user/conf"))
|
|
83
|
+
|
|
84
|
+
cfgo = OmegaConf.merge(cfgo, addo)
|
|
85
|
+
|
|
86
|
+
compare_configs(cfg, cfgo)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .src import initialize_modules, update_modules, finalize_modules, setup_igm_modules
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
# Copyright (C) 2021-2025 IGM authors
|
|
5
|
+
Published under the GNU GPL (Version 3), check at the LICENSE file
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
import importlib
|
|
10
|
+
from typing import List, Tuple
|
|
11
|
+
from types import ModuleType
|
|
12
|
+
from hydra.core.hydra_config import HydraConfig
|
|
13
|
+
|
|
14
|
+
from .utils import get_module_name, get_orders
|
|
15
|
+
from .validator import validate_module
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def load_modules(
|
|
19
|
+
cfg, state
|
|
20
|
+
) -> Tuple[List[ModuleType], List[ModuleType], List[ModuleType]]:
|
|
21
|
+
"""Returns a list of actionable modules to then apply the update, initialize, finalize functions on for IGM."""
|
|
22
|
+
imported_input_modules = []
|
|
23
|
+
imported_modules = []
|
|
24
|
+
imported_output_modules = []
|
|
25
|
+
|
|
26
|
+
root_foldername = (
|
|
27
|
+
f"{HydraConfig.get().runtime.cwd}/{cfg.core.structure.root_foldername}"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Add custom modules folder to sys.path
|
|
31
|
+
user_input_modules_folder = f"{root_foldername}/{cfg.core.structure.code_foldername}/{cfg.core.structure.input_modules_foldername}"
|
|
32
|
+
user_process_modules_folder = f"{root_foldername}/{cfg.core.structure.code_foldername}/{cfg.core.structure.process_modules_foldername}"
|
|
33
|
+
user_output_modules_folder = f"{root_foldername}/{cfg.core.structure.code_foldername}/{cfg.core.structure.output_modules_foldername}"
|
|
34
|
+
|
|
35
|
+
custom_modules_folders = [
|
|
36
|
+
user_input_modules_folder,
|
|
37
|
+
user_process_modules_folder,
|
|
38
|
+
user_output_modules_folder,
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
for folder in custom_modules_folders:
|
|
42
|
+
if folder not in sys.path:
|
|
43
|
+
sys.path.append(folder)
|
|
44
|
+
|
|
45
|
+
if "inputs" in cfg:
|
|
46
|
+
load_user_modules(
|
|
47
|
+
cfg=cfg,
|
|
48
|
+
state=state,
|
|
49
|
+
modules_list=cfg.inputs,
|
|
50
|
+
imported_modules_list=imported_input_modules,
|
|
51
|
+
module_folder=user_input_modules_folder,
|
|
52
|
+
)
|
|
53
|
+
load_modules_igm(
|
|
54
|
+
cfg=cfg,
|
|
55
|
+
state=state,
|
|
56
|
+
modules_list=cfg.inputs,
|
|
57
|
+
imported_modules_list=imported_input_modules,
|
|
58
|
+
module_type="inputs",
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
if "processes" in cfg:
|
|
62
|
+
load_user_modules(
|
|
63
|
+
cfg=cfg,
|
|
64
|
+
state=state,
|
|
65
|
+
modules_list=cfg.processes,
|
|
66
|
+
imported_modules_list=imported_modules,
|
|
67
|
+
module_folder=user_process_modules_folder,
|
|
68
|
+
)
|
|
69
|
+
load_modules_igm(
|
|
70
|
+
cfg=cfg,
|
|
71
|
+
state=state,
|
|
72
|
+
modules_list=cfg.processes,
|
|
73
|
+
imported_modules_list=imported_modules,
|
|
74
|
+
module_type="processes",
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
if "outputs" in cfg:
|
|
78
|
+
load_user_modules(
|
|
79
|
+
cfg=cfg,
|
|
80
|
+
state=state,
|
|
81
|
+
modules_list=cfg.outputs,
|
|
82
|
+
imported_modules_list=imported_output_modules,
|
|
83
|
+
module_folder=user_output_modules_folder,
|
|
84
|
+
)
|
|
85
|
+
load_modules_igm(
|
|
86
|
+
cfg=cfg,
|
|
87
|
+
state=state,
|
|
88
|
+
modules_list=cfg.outputs,
|
|
89
|
+
imported_modules_list=imported_output_modules,
|
|
90
|
+
module_type="outputs",
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# Reorder modules
|
|
94
|
+
input_order, module_order, output_order = get_orders()
|
|
95
|
+
|
|
96
|
+
input_order_dict = {name: index for index, name in enumerate(input_order)}
|
|
97
|
+
imported_input_modules = sorted(
|
|
98
|
+
imported_input_modules,
|
|
99
|
+
key=lambda module: input_order_dict[get_module_name(module)],
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
modules_order_dict = {name: index for index, name in enumerate(module_order)}
|
|
103
|
+
imported_modules = sorted(
|
|
104
|
+
imported_modules, key=lambda module: modules_order_dict[get_module_name(module)]
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
output_order_dict = {name: index for index, name in enumerate(output_order)}
|
|
108
|
+
imported_output_modules = sorted(
|
|
109
|
+
imported_output_modules,
|
|
110
|
+
key=lambda module: output_order_dict[get_module_name(module)],
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
if cfg.core.print_imported_modules:
|
|
114
|
+
print(f"{'':-^100}")
|
|
115
|
+
print(f"{'INPUTS Modules':-^100}")
|
|
116
|
+
for i, input_module in enumerate(imported_input_modules):
|
|
117
|
+
print(f" {i}: {input_module}")
|
|
118
|
+
print(f"{'PROCESSES Modules':-^100}")
|
|
119
|
+
for i, module in enumerate(imported_modules):
|
|
120
|
+
print(f" {i}: {module}")
|
|
121
|
+
print(f"{'OUTPUTS Modules':-^100}")
|
|
122
|
+
for i, output_module in enumerate(imported_output_modules):
|
|
123
|
+
print(f" {i}: {output_module}")
|
|
124
|
+
print(f"{'':-^100}")
|
|
125
|
+
|
|
126
|
+
return imported_input_modules, imported_modules, imported_output_modules
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def load_user_modules(
|
|
130
|
+
cfg, state, modules_list, imported_modules_list, module_folder
|
|
131
|
+
) -> List[ModuleType]:
|
|
132
|
+
|
|
133
|
+
from importlib.machinery import SourceFileLoader
|
|
134
|
+
|
|
135
|
+
for module_name in modules_list:
|
|
136
|
+
# Local Directory
|
|
137
|
+
try:
|
|
138
|
+
module = SourceFileLoader(
|
|
139
|
+
f"{module_name}", f".{module_name}.py"
|
|
140
|
+
).load_module()
|
|
141
|
+
except FileNotFoundError:
|
|
142
|
+
|
|
143
|
+
# User Modules Folder
|
|
144
|
+
try:
|
|
145
|
+
module = SourceFileLoader(
|
|
146
|
+
f"{module_name}", f"{module_folder}/{module_name}.py"
|
|
147
|
+
).load_module()
|
|
148
|
+
except FileNotFoundError:
|
|
149
|
+
# User Modules Folder Folder
|
|
150
|
+
try:
|
|
151
|
+
module = SourceFileLoader(
|
|
152
|
+
f"{module_name}",
|
|
153
|
+
f"{module_folder}/{module_name}/{module_name}.py",
|
|
154
|
+
).load_module()
|
|
155
|
+
except FileNotFoundError:
|
|
156
|
+
pass
|
|
157
|
+
else:
|
|
158
|
+
imported_modules_list.append(module)
|
|
159
|
+
else:
|
|
160
|
+
imported_modules_list.append(module)
|
|
161
|
+
else:
|
|
162
|
+
imported_modules_list.append(module)
|
|
163
|
+
|
|
164
|
+
return imported_modules_list
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def load_modules_igm(
|
|
168
|
+
cfg, state, modules_list, imported_modules_list, module_type
|
|
169
|
+
) -> List[ModuleType]:
|
|
170
|
+
|
|
171
|
+
from importlib.machinery import SourceFileLoader
|
|
172
|
+
|
|
173
|
+
imported_modules_names = [module.__name__ for module in imported_modules_list]
|
|
174
|
+
for module_name in modules_list:
|
|
175
|
+
if module_name in imported_modules_names:
|
|
176
|
+
continue
|
|
177
|
+
|
|
178
|
+
module_path = f"igm.{module_type}.{module_name}"
|
|
179
|
+
module = importlib.import_module(module_path)
|
|
180
|
+
if module_type == "processes":
|
|
181
|
+
validate_module(module)
|
|
182
|
+
imported_modules_list.append(module)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from typing import List, Any
|
|
2
|
+
from types import ModuleType
|
|
3
|
+
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
from ...core import State
|
|
7
|
+
from ...utilities import print_info
|
|
8
|
+
from ..modules.loader import load_modules
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def initialize_modules(processes: List, cfg: Any, state: State) -> None:
|
|
12
|
+
for module in processes:
|
|
13
|
+
if cfg.core.logging:
|
|
14
|
+
state.logger.info(f"Initializing module: {module.__name__.split('.')[-1]}")
|
|
15
|
+
module.initialize(cfg, state)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def update_modules(processes: List, outputs: List, cfg: Any, state: State) -> None:
|
|
19
|
+
|
|
20
|
+
state.it = 0
|
|
21
|
+
state.continue_run = True
|
|
22
|
+
if cfg.core.print_comp:
|
|
23
|
+
state.tcomp = {
|
|
24
|
+
module.__name__.split(".")[-1]: [] for module in processes + outputs
|
|
25
|
+
}
|
|
26
|
+
while state.continue_run:
|
|
27
|
+
for module in processes:
|
|
28
|
+
m = module.__name__.split(".")[-1]
|
|
29
|
+
if cfg.core.print_comp:
|
|
30
|
+
state.tcomp[m].append(time.time())
|
|
31
|
+
module.update(cfg, state)
|
|
32
|
+
if cfg.core.print_comp:
|
|
33
|
+
state.tcomp[m][-1] -= time.time()
|
|
34
|
+
state.tcomp[m][-1] *= -1
|
|
35
|
+
run_outputs(outputs, cfg, state)
|
|
36
|
+
if cfg.core.print_info:
|
|
37
|
+
print_info(state)
|
|
38
|
+
state.it += 1
|
|
39
|
+
|
|
40
|
+
if not hasattr(state, "t"):
|
|
41
|
+
state.continue_run = False
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def finalize_modules(processes: List, cfg: Any, state: State) -> None:
|
|
45
|
+
for module in processes:
|
|
46
|
+
module.finalize(cfg, state)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def run_outputs(output_modules: List, cfg: Any, state: State) -> None:
|
|
50
|
+
for module in output_modules:
|
|
51
|
+
m = module.__name__.split(".")[-1]
|
|
52
|
+
if cfg.core.print_comp:
|
|
53
|
+
state.tcomp[m].append(time.time())
|
|
54
|
+
module.run(cfg, state)
|
|
55
|
+
if cfg.core.print_comp:
|
|
56
|
+
state.tcomp[m][-1] -= time.time()
|
|
57
|
+
state.tcomp[m][-1] *= -1
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def setup_igm_modules(cfg, state) -> List[ModuleType]:
|
|
61
|
+
return load_modules(cfg, state)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from hydra.core.hydra_config import HydraConfig
|
|
2
|
+
import yaml
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def get_orders():
|
|
6
|
+
config_path = [
|
|
7
|
+
path["path"]
|
|
8
|
+
for path in HydraConfig.get().runtime.config_sources
|
|
9
|
+
if path["schema"] == "file"
|
|
10
|
+
][0]
|
|
11
|
+
|
|
12
|
+
with open(
|
|
13
|
+
f"{config_path}/experiment/{HydraConfig.get().runtime.choices.experiment}.yaml",
|
|
14
|
+
"r",
|
|
15
|
+
) as file:
|
|
16
|
+
original_experiment_config = yaml.safe_load(file)
|
|
17
|
+
|
|
18
|
+
defaults = original_experiment_config["defaults"]
|
|
19
|
+
input_order = modules_order = output_order = []
|
|
20
|
+
for default in defaults:
|
|
21
|
+
|
|
22
|
+
key = list(default.keys())[0] # ? Cleaner / more robust way to do this?
|
|
23
|
+
if key == "override /inputs":
|
|
24
|
+
input_order = default[key]
|
|
25
|
+
elif key == "override /processes":
|
|
26
|
+
modules_order = default[key]
|
|
27
|
+
elif key == "override /outputs":
|
|
28
|
+
output_order = default[key]
|
|
29
|
+
|
|
30
|
+
return input_order, modules_order, output_order
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def get_module_name(module):
|
|
34
|
+
return module.__name__.split(".")[-1]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
def validate_module(module) -> None:
|
|
2
|
+
"""Validates that a module has the required functions to be used in IGM."""
|
|
3
|
+
required_functions = ["initialize", "finalize", "update"]
|
|
4
|
+
for function in required_functions:
|
|
5
|
+
if not hasattr(module, function):
|
|
6
|
+
raise AttributeError(
|
|
7
|
+
f"Module {module} is missing the required function ({function}). If it is a custom python package, make sure to include the 3 required functions: ['initialize', 'finalize', 'update'].",
|
|
8
|
+
f"Please see https://github.com/jouvetg/igm/wiki/5.-Custom-modules-(coding) for more information on how to construct custom modules.",
|
|
9
|
+
)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def download_unzip_and_store(url, folder_path) -> None:
|
|
5
|
+
"""
|
|
6
|
+
Use wget to download a ZIP file and unzip its contents to a specified folder.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
- url (str): The URL of the ZIP file to download.
|
|
10
|
+
- folder_path (str): The path of the folder where the ZIP file's contents will be extracted.
|
|
11
|
+
# - folder_name (str): The name of the folder where the ZIP file's contents will be extracted.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import subprocess
|
|
15
|
+
import os
|
|
16
|
+
import zipfile
|
|
17
|
+
|
|
18
|
+
# Ensure the destination folder exists
|
|
19
|
+
if not os.path.exists(folder_path): # directory exists?
|
|
20
|
+
os.makedirs(folder_path)
|
|
21
|
+
|
|
22
|
+
# Download the file with wget
|
|
23
|
+
logging.info("Downloading the ZIP file with wget...")
|
|
24
|
+
subprocess.run(["wget", "-O", "downloaded_file.zip", url])
|
|
25
|
+
|
|
26
|
+
# Unzipping the file
|
|
27
|
+
logging.info("Unzipping the file...")
|
|
28
|
+
with zipfile.ZipFile("downloaded_file.zip", "r") as zip_ref:
|
|
29
|
+
zip_ref.extractall(folder_path)
|
|
30
|
+
|
|
31
|
+
# Clean up (delete) the zip file after extraction
|
|
32
|
+
os.remove("downloaded_file.zip")
|
|
33
|
+
logging.info(f"File successfully downloaded and extracted to '{folder_path}'")
|
|
34
|
+
|
|
35
|
+
else:
|
|
36
|
+
logging.info(f"The data already exists at '{folder_path}'")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def add_logger(cfg, state) -> None:
|
|
40
|
+
|
|
41
|
+
# ! Ignore logging file for now...
|
|
42
|
+
# if cfg.logging_file == "":
|
|
43
|
+
# pathf = ""
|
|
44
|
+
# else:
|
|
45
|
+
# pathf = cfg.logging_file
|
|
46
|
+
|
|
47
|
+
logging.basicConfig(
|
|
48
|
+
# filename=pathf,
|
|
49
|
+
encoding="utf-8",
|
|
50
|
+
filemode="w",
|
|
51
|
+
level=cfg.core.logging_level,
|
|
52
|
+
format="%(asctime)s - %(levelname)s - %(message)s",
|
|
53
|
+
)
|
|
54
|
+
logging.root.setLevel(cfg.core.logging_level)
|
|
55
|
+
|
|
56
|
+
state.logger = logging.getLogger("igm")
|