Compare commits

...
422 Commits
Author SHA1 Message Date
parouby fef2a2e979 Pamhyr: Fix pep8. 2026-09-15 17:33:51 +02:00
parouby f001dffb68 Ensemble: PlotRKC: Minor change. 2026-09-15 17:29:37 +02:00
parouby 2818644b7f Ensemble: Distribution: Add default values for each distribution. 2026-09-15 16:57:00 +02:00
parouby 86d93fd702 Ensemble: Ui: Minor change. 2026-09-15 16:47:26 +02:00
parouby 593cc0c91b Ensemble: Mage: Fix iterative mean computation. 2026-09-15 16:32:27 +02:00
parouby 32a316589b Ensemble: Rename 'run_number' to 'number_of_run' and fix seed spin box max value. 2026-09-10 16:49:11 +02:00
parouby d4bc9bdf75 Ensemble: Set custom seed. 2026-09-10 16:39:38 +02:00
parouby 3325ba935b Ensemble: Run: Add function combobox and seed spin box. 2026-09-10 16:17:57 +02:00
parouby 345f24996f Ensemble: Rename function to disctribution. 2026-09-10 15:56:29 +02:00
parouby 4040b2456c Ensemble: Function: Add Poisson law and 1 params dialog. 2026-09-10 15:09:24 +02:00
parouby 8e77d31a5a Ensemble: Add normal low and generalise minmaxdialog. 2026-09-10 14:57:48 +02:00
parouby 6e029beafc Ensemble: Function: Rename get_sample to random and use np.random. 2026-09-10 11:40:57 +02:00
parouby f5a7cd5984 Ensemble: PlotH: Add ensemble ploth. 2026-09-10 11:14:03 +02:00
parouby d4d5e26a2b Ensemble: Results: Rename Z to z_mean and dont keep individual result. 2026-09-10 10:44:03 +02:00
parouby 92990948ad Ensemble: PlotRKC: Fix table selection plot update. 2026-09-10 10:31:30 +02:00
parouby bf6d40f398 Ensemble: Results: PlotRKC: Add legend. 2026-09-08 17:50:51 +02:00
parouby 03299db99a Ensemble: Results: PlotRKC: Fix table access. 2026-09-08 16:33:29 +02:00
parouby a0886d900e Results: PlotRKC: Minor change to optimize drawing. 2026-09-08 16:04:19 +02:00
parouby 97fe038d9b Ensemble: Fix open results. 2026-09-08 15:08:11 +02:00
parouby 58e3da8942 Ensemble: Add base for RKC ensemble plot. 2026-09-04 17:51:52 +02:00
parouby b7c3793a66 Geometry: Point: Fix index creation. 2026-09-04 11:31:23 +02:00
parouby 2498466a51 Ensemble: Results: Fix runs table. 2026-09-04 10:31:04 +02:00
parouby ef36eba039 Ensemble: Results: Add method to open ensemble results window. 2026-09-04 10:11:46 +02:00
parouby c40e28ed0f Ensemble: Results: Add ui file for results window. 2026-09-03 16:21:53 +02:00
parouby b21846a513 Ensemble: Results: Add base of 'ResultsEnsembleWindow' obj. 2026-09-03 16:17:49 +02:00
parouby 3532f75c2b Solver: Mage: Minor change. 2026-09-02 16:21:31 +02:00
parouby 6c59919972 Pep8: Fix. 2026-09-01 11:36:35 +02:00
parouby 77d56b8bec Ensemble: Keep results nim, mean and max for each run. 2026-09-01 11:34:37 +02:00
parouby 7ef7bc13dc Ensemble: Continue to adapt results. 2026-08-28 16:15:59 +02:00
parouby a1d85274b9 Ensemble: Put ensemble results data into results obj. 2026-08-28 11:10:29 +02:00
parouby e7b9bc92a2 Ensemble: Run: Log variation. 2026-08-27 10:10:08 +02:00
parouby 7d8e414fe2 Ensemble: Fix missing requirements 'psutil'. 2026-08-27 09:48:12 +02:00
parouby 476bcc9c55 Ensemble: Made it compatible with other solver than mage8. 2026-08-27 09:44:03 +02:00
parouby ae006f52f4 Ensemble: Table: Fix double assignation for data type and target. 2026-08-26 16:04:58 +02:00
parouby 3583a93ae0 Ensemble: Set ensemble as read only study (except for ensemble). 2026-08-25 17:07:34 +02:00
parouby 212a00a43c Ensemble: Fix missing file. 2026-08-25 14:42:41 +02:00
parouby e5dbba362a Debug: Add memory usage to debug timer window. 2026-08-21 16:55:50 +02:00
parouby bdc09addfa Ensemble: Fix results reading. 2026-08-21 16:55:17 +02:00
parouby 51b3987a4a Mage: Ensemble: Add bin reading method. 2026-08-21 15:28:17 +02:00
parouby e7290fa81b Ensemble: Fix ensemble study meta data save. 2026-08-21 15:27:17 +02:00
parouby b5432498c6 Ensemble: Add sequential runs with RUG variation into mage export. 2026-08-20 16:00:40 +02:00
parouby 807592eab2 Ensemble: Rename 'range' to 'params'. 2026-08-14 16:33:41 +02:00
parouby 394c0779fc Ensemble: Add min max dialog for range. 2026-08-14 16:30:27 +02:00
parouby 5b3f777100 Ensemble: Minor change and add target data to table. 2026-08-14 09:27:39 +02:00
parouby 8b36905842 Ensemble: Fix some view/model interations. 2026-08-14 09:27:36 +02:00
parouby b203e8e062 Ensemble: Fix editing ensemble list. 2026-08-12 16:46:13 +02:00
parouby 4d4df1bde2 Ensemble: Function: Randomize Uniform sample. 2026-08-12 15:19:12 +02:00
parouby 876780a349 Ensembles: Open Ensemble windows from scenarios. 2026-08-12 14:50:58 +02:00
parouby 3b83377f3c Ensemble: Draw ensemble scenario as rect and minor fix. 2026-08-07 16:28:13 +02:00
parouby e64c45b621 Ensemble: Create new ensemble scenario. 2026-08-07 15:18:22 +02:00
parouby 70dae9ab1b Ensemble: Prepare view with add base classes. 2026-08-06 15:33:53 +02:00
parouby 0bb3c5bc65 Ensemble: Minor change to prepare view integration. 2026-07-31 16:19:13 +02:00
parouby 54f5c7c548 Ensemble: Switch data pid to data ref, and minor change. 2026-07-30 11:14:33 +02:00
parouby 56217186ff Ensemble: Fix save/load methode. 2026-07-29 16:31:13 +02:00
parouby 82fb2bcc48 Ensemble: Change function to id and name, minor change and fix. 2026-07-29 15:19:36 +02:00
parouby 6dc42b637a Ensemble: Function: Some minor fix and add it to study. 2026-07-24 11:45:39 +02:00
parouby e6d12713e3 Ensemble: Minor change. 2026-07-24 10:04:15 +02:00
parouby 9456cf32fc Ensemble: Function: Add base classes. 2026-07-24 10:02:25 +02:00
parouby 9b1fb4e7d2 Ensemble: Add ensemble base classes. 2026-07-23 09:51:17 +02:00
parouby c09c62f077 Merge: Results reading optimisation. 2026-07-10 10:18:58 +02:00
parouby 7a2e93a995 Results: Custom plot: Minor change. 2026-07-10 09:16:05 +02:00
parouby 5327c29641 Results: Custom plot: Use 'zfd' np table. 2026-07-09 18:05:10 +02:00
parouby be865102a8 Results: Put 'zfd' data into np table. 2026-07-09 16:53:48 +02:00
parouby 37f1b43b93 Debug: Fix pep8. 2026-07-09 10:16:23 +02:00
parouby 16f0775783 Pamhyr: Update all copyright. 2026-07-09 10:13:06 +02:00
parouby f2c4285b4c Debug: Minor change. 2026-07-09 09:03:11 +02:00
parouby ee95f0e89e Debug: Add csv export method. 2026-07-08 17:55:31 +02:00
parouby 1306977954 Debug: Add Timer window. 2026-07-08 16:38:41 +02:00
parouby 476fa81bc2 Results: Plot{AC,RKC}: Fix max elevation and minor change. 2026-07-07 21:56:19 +02:00
parouby e8f1f0ac43 Results: Add TableData pamhyr object for np table. 2026-07-03 17:03:33 +02:00
Dylan Jeannin cfbc2d96a1 Mage: Fix parsing for .LAT files 2026-07-03 13:07:10 +02:00
parouby 1adf24ce77 Geometry: ProfileXYZ: Minor optimisation of computation. 2026-07-02 15:04:33 +02:00
parouby a61d130baa Solver: Mage: Comment setter Z, Q and V into profile and bufferize and fix indent. 2026-07-02 11:43:00 +02:00
parouby 0a1760cee6 Results: CustomPlot: Continue to switch to np table. 2026-07-02 11:00:51 +02:00
parouby 3e094af325 Results: CustomPlot: Use np table. 2026-07-01 17:54:34 +02:00
parouby 762e4d70a0 Results: Exports: Use np.{min,max}. 2026-07-01 17:54:08 +02:00
parouby 6c4f863b96 Results: Export: Use np table. 2026-07-01 15:39:52 +02:00
parouby b87f82f74d Results: PlotRKC: Use table to get results table. 2026-06-30 16:57:42 +02:00
parouby ffad53a331 Results: Table: Use results tables. 2026-06-30 15:30:44 +02:00
parouby 662a218e41 Results: Reach: Keep profiles global min and max. 2026-06-26 16:51:58 +02:00
parouby 0501ae9bec Solver: Mage: read_bin: Use np table for velocity computation. 2026-06-26 16:20:32 +02:00
parouby 7fd38eec00 Results: Table: Minor change. 2026-06-26 14:54:55 +02:00
parouby 4bab4580ad Results: PlotXY: Use table Z to display max elevation. 2026-06-26 14:41:24 +02:00
parouby 21d2e6ad20 Results: PlotAC: Use Z table. 2026-06-26 14:23:00 +02:00
parouby d0a8f369ef Results: PlotH: Use np table. 2026-06-26 14:05:29 +02:00
parouby fef2e1a40c Results: PlotXY: Minor change. 2026-06-26 10:51:36 +02:00
parouby 20c2cb7ea4 Merge branch 'master' into opt-result 2026-06-26 09:29:39 +02:00
parouby 64a26e987e ci: Fix again. 2026-06-25 15:48:41 +02:00
parouby eb233847de ci: Fix pipeline for release. 2026-06-25 15:42:46 +02:00
parouby 7bb810d427 Pollutants: Fix 'enabled' column update version. 2026-06-25 15:00:41 +02:00
Dylan Jeannin e49724072b Merge branch 'dev_dylan' into scenarios 2026-06-25 14:41:24 +02:00
Dylan Jeannin 3664ba93e9 Results: Fix open mage results from AdisTS solver 2026-06-25 14:39:45 +02:00
Dylan Jeannin a9903e987b AdisTS: Resolve bug with node ids not matching in config files 2026-06-25 14:05:04 +02:00
Dylan Jeannin f9a88a211c Fix pep8 2026-06-22 17:10:57 +02:00
Dylan Jeannin 32535af3e6 UpdateRK: avoid crash when updating RK with missing points on a section, warning message instead 2026-06-22 17:04:39 +02:00
Dylan Jeannin fa8948c1b6 Meshing: Debug error caused by index out of range when adding an empty transect on a reach 2026-06-22 15:18:08 +02:00
Dylan Jeannin 2d5455c09d Meshing: Debug crashing case when divide by 0 2026-06-22 14:16:33 +02:00
Dylan Jeannin 83680bbe57 Pollutant: quickfix, back to previous version 2026-06-22 12:12:02 +02:00
Dylan Jeannin 1d1a00a0ff Pollutants: merge conflicts 2026-06-22 10:42:29 +02:00
Dylan Jeannin ffd95b9fdf Pollutants: merge conflicts 2026-06-22 10:42:07 +02:00
parouby ecb2544cab Results: Keep timestamps index table. 2026-06-19 15:25:40 +02:00
parouby 9c66021b53 Results: Give access profiles to np table and keep profile global id. 2026-06-19 14:54:26 +02:00
parouby 8255fc3c1b River: Add some timer. 2026-06-19 09:23:42 +02:00
parouby 32e7413aad Solver: Mage: read_bin: Put velocity into np table. 2026-06-18 15:45:11 +02:00
parouby d87db5fd48 Solver: Mage: read_bin: Optimize iprofiles. 2026-06-18 15:02:34 +02:00
parouby 388368adad Solver: Mage: Add data np table to results. 2026-06-18 14:29:50 +02:00
parouby 4d014d5a1d Results: Minor change. 2026-06-18 10:11:17 +02:00
parouby 181a6c226f Geometry: ProfileXYZ: Add 'get_all_water_limits_ac' cache. 2026-06-18 10:09:51 +02:00
parouby 1975ed7eaa Profile: Create cache for 'get_water_limits' results. 2026-06-17 17:41:06 +02:00
parouby 565a7530fb Results: Minor results reading optimisation with async computation. 2026-06-17 17:04:58 +02:00
parouby 32cbc6bc3e Results: Fix additional geotiff display. 2026-06-16 17:28:55 +02:00
parouby 7d7a05c04c Results: Minor change. 2026-06-16 16:28:46 +02:00
parouby 6ac268b668 Results: Add data: Move update to plot class. 2026-06-16 16:24:05 +02:00
parouby 19c72892a8 Results: Add data: Hydrogram: Move drawing to plot. 2026-06-16 16:13:10 +02:00
parouby 9717968e08 Mage: LC: Fix export. 2026-06-10 14:26:05 +02:00
parouby e19c3229bd Solver: Mage: HS: Minor change. 2026-06-05 17:01:22 +02:00
parouby b3c6f1031b Solver: Mage: Minor change. 2026-06-05 16:35:57 +02:00
parouby c2d93b4a4a MainWindow: Finally connect action for the 'Quit' menu action. 2026-06-05 15:56:25 +02:00
parouby 76430322dd Results: Minor change. 2026-06-05 14:59:48 +02:00
parouby 31ae0ab8e0 Study: Add minor comment. 2026-06-05 10:54:51 +02:00
parouby 8182d434ec GeoTIFF: Fix crashes at 'cannot remove artist'. 2026-06-05 10:01:53 +02:00
parouby da78d0cdb1 AdisTS: Fix mage result workdir and add scenario into paths. 2026-06-04 15:21:03 +02:00
parouby 850db144ac WaitingDialog: Fix windows size. 2026-06-04 14:53:43 +02:00
parouby 0f6709075f Scenarios: Merge branch 'master' into scenarios. 2026-06-04 14:03:49 +02:00
parouby e86b84b0b9 AdisTS: Results: Fix db save. 2026-06-03 16:00:12 +02:00
parouby e08d212986 AdisTS: D90: Fix reach pid update. 2026-06-03 15:34:52 +02:00
parouby 7b88d955e5 Geometry: Update RK refactoring and fix modified flag. 2026-06-02 16:46:30 +02:00
parouby d1c34fb437 Pamhyr: Fix PEP8. 2026-06-02 15:40:51 +02:00
parouby 611f9cdfa3 Trad: Minor change. 2026-06-02 15:16:50 +02:00
parouby bd2fc22e96 Results: Fix non valid results save. 2026-06-02 15:11:07 +02:00
parouby efa16837d8 AdisTS: Minor change. 2026-05-28 17:09:02 +02:00
parouby db7aad26fd Geometry: Point: Optimize loading with indexing and update db to 0.2.5. 2026-05-28 17:09:02 +02:00
parouby 229b3da2d1 AdistTS: Fix update with table exists tests. 2026-05-28 17:09:02 +02:00
Dylan Jeannin 48d6728e1e Enable pollutant: fix the list to browse to enable a pol 2026-05-28 15:11:06 +02:00
Dylan Jeannin c51c06e6ec DB version: Upgrade to add enabled in pollutants db 2026-05-28 15:02:40 +02:00
Dylan Jeannin a425c9a6ac BoundaryConditions: delete setter/getter duplicated for d50 and sigma 2026-05-28 15:01:36 +02:00
Dylan Jeannin e79ae8ebf5 Translation: new version of .ts file, with type of pollutants added 2026-05-28 13:01:48 +02:00
Dylan Jeannin e3020d15ba Merge branch 'scenarios' into dev_dylan 2026-05-28 11:56:00 +02:00
Dylan Jeannin 83e0ecbdc7 PEP8 fix 2026-05-28 11:54:44 +02:00
Dylan Jeannin 3087023caa Pollutants: Add translation for type of pol 2026-05-28 11:52:43 +02:00
parouby 7e080767da AdistTS: d90: Fix update to 0.2.*. 2026-05-28 10:27:05 +02:00
parouby 44c3a91d72 AdisTS: Fix db version update (again) for 0.0.11 2026-05-28 10:27:05 +02:00
Dylan Jeannin 26dc7d8761 Merge branch 'scenarios' of https://gitlab.com/pamhyr/pamhyr2 into scenarios 2026-05-27 09:35:46 +02:00
Dylan Jeannin e573fa4197 Pollutants: specific way to check if we modified the data in the type combobox 2026-05-27 09:35:10 +02:00
parouby 7aa0cf4361 AdisTS: Fix db update. 2026-05-26 18:00:05 +02:00
parouby c3faf45f75 SolverLogFileWindow: Add exeption to fix crash for #48. 2026-05-26 16:36:27 +02:00
Dylan Jeannin fb8b5aa77f Translation: back to old fr.ts version which broke translation* 2026-05-26 14:56:31 +02:00
Dylan Jeannin 8183a284af Merge branch 'pollutant_type_combobox' into dev_dylan 2026-05-26 12:27:44 +02:00
Dylan Jeannin 09997a0074 Tables: Skip table undo commands when data is unchanged (avoid data duplicates in db) 2026-05-26 12:27:41 +02:00
Dylan Jeannin c44597dfbd Merge branch 'dev_dylan' into scenarios 2026-05-26 11:15:32 +02:00
Dylan Jeannin b1632eaea5 Fix PEP8 2026-05-26 11:14:57 +02:00
Dylan Jeannin a2461af084 Scenario: avoid marking loaded scenario data as modified, that created unwanted copies in database 2026-05-26 11:12:36 +02:00
parouby 5c366839f3 Results: Fix db save where results do not correspond to scenario. 2026-05-26 10:28:41 +02:00
parouby 311df46a2c Friction: Fix save and delete method. 2026-05-26 10:28:41 +02:00
Dylan Jeannin a235f61044 PEP8 fixes 2026-05-26 08:15:04 +02:00
Dylan Jeannin 0b80b86d31 Merge branch 'dev_dylan' into scenarios 2026-05-26 08:10:34 +02:00
Dylan Jeannin 0c7ede5f43 Network: Add missing () on method to check if study is editable 2026-05-26 08:06:07 +02:00
Dylan Jeannin 445c1ac7ba Scenario: Add ⛔ symbol on missing windows when we are not in a leaf scenario 2026-05-26 07:42:08 +02:00
Dylan Jeannin c687e05d8f Pollutant types: Add type combobox with readable names 2026-05-22 18:36:28 +02:00
Dylan Jeannin 5fb6fecc24 Scenarios: Set parent to EDIT when deleting current scenario 2026-05-22 17:25:44 +02:00
Dylan Jeannin 3dfbdc328e PEP8 fix 2026-05-22 16:54:35 +02:00
Dylan Jeannin 97d87f2455 Merge branch 'scenarios' of https://gitlab.com/pamhyr/pamhyr2 into scenarios 2026-05-22 16:52:50 +02:00
Dylan Jeannin a78be47e2b AdisTS: Fix the possibility to edit AdisTS windows on a parent scenario 2026-05-22 16:47:02 +02:00
Dylan Jeannin eed2ce4243 Pollutants: Fix setters from undo/redo commands on edition 2026-05-22 15:25:11 +02:00
parouby 78ba7b70b4 AdisTS: OutputRK: Fix save methode. 2026-05-22 14:53:38 +02:00
Dylan Jeannin f86cd4602c Merge branch 'scenarios' into dev_dylan 2026-05-22 14:38:52 +02:00
Dylan Jeannin ee28afac86 HydraulicStructures: Fix hydraulic structures plot with missing input section 2026-05-22 12:57:34 +02:00
Dylan Jeannin 81ff6372e9 LateralSources: Debug of crash on RK selection 2026-05-22 12:45:27 +02:00
parouby 61156f1c3e Scenario: Fix scenario duplication. 2026-05-22 11:51:18 +02:00
parouby e26b170b05 Network: Fix reach selection where the study is read only. 2026-05-22 10:57:49 +02:00
Dylan Jeannin ddbaa0fb94 Pollutants: Fixed pollutant deletion removing the absolute index instead of the relative index 2026-05-22 10:53:07 +02:00
parouby 64d2b2678a Geometry: Profiles: Fix shift methode. 2026-05-22 10:39:10 +02:00
parouby 3a3b5ea2dd PamhyrDB: Minor change. 2026-05-22 10:09:34 +02:00
parouby 7cb3ac8a80 Clean code: Remove some print function call. 2026-05-22 09:42:32 +02:00
parouby 190ca5d171 Scenario: Add some save dialog. 2026-05-22 09:22:35 +02:00
parouby 5d8ec51417 Scenario: Remove posibility to remove non leaf scenario. 2026-05-22 09:21:55 +02:00
parouby d922436ada Scenario: Add Discard option to scenario switching dialog. 2026-05-21 16:26:51 +02:00
parouby 4537a829af WaitingDialog: Try fix deadlock. 2026-05-21 16:26:47 +02:00
parouby 363b9c7132 Scenario: Add HS to memory clean and minor comment change. 2026-05-21 15:07:18 +02:00
parouby f9d83ac68c Scenario: Add memory clean for Pamhyr list, dict and reaches. 2026-05-21 11:17:45 +02:00
Dylan Jeannin 63b5cbaba7 debug pollutants model and save in db 2026-05-20 17:17:51 +02:00
Dylan Jeannin 1989914aef error in the name of a db table 2026-05-20 10:48:37 +02:00
Dylan Jeannin 2c0b155baf error in the name of a db table 2026-05-20 10:40:11 +02:00
Dylan Jeannin 4d20c2457a pep8 fix 2026-05-20 10:19:52 +02:00
Dylan Jeannin 2dd9003721 merge scenario (missing tables) 2026-05-20 10:18:56 +02:00
Dylan Jeannin 94ceb44fd4 debug load study after deleting a node in the child scenario network 2026-05-20 09:51:38 +02:00
Dylan Jeannin ab50d2adf4 little fixes with variable names 2026-05-19 18:00:39 +02:00
Dylan Jeannin 0eb979256f little fixes with variable names 2026-05-19 17:59:30 +02:00
parouby 5ce94a63d3 Scenario: Clean DB add minimal comment. 2026-05-19 17:54:28 +02:00
parouby 42ea50d62e Study: Minor change. 2026-05-19 16:51:57 +02:00
parouby 0df4cf0fd5 Scenario: Clean DB. 2026-05-19 16:13:30 +02:00
Dylan Jeannin ccf3da114b fix duplication of same objects in db with when saving a child scenario 2026-05-19 16:13:21 +02:00
Dylan Jeannin 348417977d add missing tables in drop_all function, called on a scenario deletion 2026-05-19 15:58:37 +02:00
parouby 914a1f8866 Scenario: Add DB clean methode (not tested yet). 2026-05-19 12:22:20 +02:00
Dylan Jeannin cbbbeeac0b correct error that made InitialCondition addition bug 2026-05-19 11:40:03 +02:00
Dylan Jeannin c9ea726bfb correct error that made LateralContrib deletion bug 2026-05-19 11:30:38 +02:00
parouby fa88e05d91 AdisTS: BC: Fix dual sub classes dependencies. 2026-05-19 10:15:23 +02:00
parouby a6915020cb BC: Minor change. 2026-05-19 09:46:46 +02:00
Dylan Jeannin ea2287215e fix pep8 before push 2026-05-18 15:33:36 +02:00
Dylan Jeannin e940dead70 Merge branch 'dev_dylan' into scenarios 2026-05-18 15:04:37 +02:00
Theophile Terraz b6a6d54a22 Merge branch 'scenarios' of gitlab.com:pamhyr/pamhyr2 into scenarios 2026-05-12 16:17:32 +02:00
Theophile Terraz 11a95cb391 debug 2026-05-12 16:16:56 +02:00
Dylan Jeannin 084c22836b debug undo after deletion of BCA 2026-05-12 13:48:14 +02:00
Dylan Jeannin 726b81bf12 debug undo after add LateralContributionAdisTS 2026-05-12 08:40:35 +02:00
Dylan Jeannin 7c3de520d9 delete old references to pollutants in BoundaryConditionsAdisTS window 2026-05-12 08:39:58 +02:00
Dylan Jeannin b450796df5 stab window InitialCond AdisTS (undo / redo / add / delete / save / load), all should work correctly 2026-05-11 16:14:35 +02:00
Dylan Jeannin b1daadf9f2 rename variables for DIF to keep consistency 2026-05-11 14:59:48 +02:00
Dylan Jeannin c38e3ee446 correct pep8 rules 2026-05-11 14:59:14 +02:00
Dylan Jeannin 606b9919e3 stab window D90 AdisTS (undo / redo / add / delete / save / load), all should work correctly 2026-05-11 14:58:42 +02:00
Dylan Jeannin e3de7e7100 rename variable to keep consistency 2026-05-11 14:07:38 +02:00
Dylan Jeannin 92fae0e13f rename variable to keep consistency 2026-05-11 14:06:07 +02:00
Dylan Jeannin a8b260ad38 debug crash when double clic on PK combobox when no reach is selected (DIF window) 2026-05-11 13:49:54 +02:00
Dylan Jeannin faff877c80 stab window DIF AdisTS (undo / redo / add / delete / save / load), all should work correctly 2026-05-11 12:52:33 +02:00
Theophile Terraz 0a0eeb3c3f debug 2026-05-07 17:01:22 +02:00
parouby cdcbbc2cf4 doc: Remove watermark. 2026-05-06 11:03:56 +02:00
Dylan Jeannin 7565d8ee95 fix pep8 2026-05-05 17:51:49 +02:00
Dylan Jeannin 11e1302e05 fix add/del/undo/redo in edit BoundaryConditionsAdisTS + quick fix in edit LateralContributionsAdisTS 2026-05-05 17:50:45 +02:00
Dylan Jeannin 99cb2883a1 display seconds in LateralContributionAdisTS data (edition window) 2026-05-05 12:34:44 +02:00
Dylan Jeannin e61dede7f8 add Dylan in contributors 2026-05-05 12:33:41 +02:00
Dylan Jeannin cb4dfab482 conflicts resolution before merge 2026-05-05 10:50:42 +02:00
Dylan Jeannin 377c508038 correction pep8 2026-05-05 10:29:13 +02:00
Dylan Jeannin 30e34b6847 debug add function and save/load in db for edit LCAdisTS window 2026-05-05 10:28:30 +02:00
Dylan Jeannin 102702e1df fix delete function for BCAdisTS 2026-05-04 14:52:31 +02:00
Dylan Jeannin c014f0ef34 erase old and useless methods 2026-05-04 14:51:34 +02:00
Dylan Jeannin e615a6b9d4 debug index matching in delete function for LCAdisTS 2026-05-04 13:03:18 +02:00
Dylan Jeannin f1dca727c6 rename edition BCadisTS and LCadisTS windows 2026-05-04 11:11:23 +02:00
Dylan Jeannin 2db1f4c7f7 fix tab elts related to pollutants, and fix add/del functionnality for LateralContributionAdisTS 2026-04-30 15:56:11 +02:00
Dylan Jeannin b3d631943c correction bug with saving data for lateral contributions adisTS 2026-04-29 15:33:00 +02:00
Dylan Jeannin b6895ae99c correction bug with saving data for lateral contributions adisTS 2026-04-29 14:09:34 +02:00
Dylan Jeannin 9f26a7323c correction bug with saving data for lateral contributions adisTS 2026-04-29 14:03:58 +02:00
Dylan Jeannin 2a7e322ee5 fix name of window InitCondAdisTS to mention pollutant name 2026-04-28 16:44:33 +02:00
Dylan Jeannin 13a44264ac fix pep8 rules 2026-04-28 16:05:40 +02:00
Dylan Jeannin 6165719829 warning popup when export format for geometry reach is not .st 2026-04-28 14:30:40 +02:00
Dylan Jeannin 51dd6d27c5 try fix ci pipeline 2026-04-28 13:31:39 +02:00
Dylan Jeannin cea4dcd9cb refacto variable names for D90 2026-04-28 11:06:57 +02:00
Dylan Jeannin e1c1f411c3 fix bug when add button didnt refresh the tab list in Initial conditions AdisTS and d90 2026-04-28 11:06:57 +02:00
Dylan Jeannin 4550fc95d7 debug delete functionnality in InitialConditionsAdisTS 2026-04-28 11:06:57 +02:00
Dylan Jeannin 1f97af9c03 clean useless data 2026-04-28 11:06:57 +02:00
Dylan Jeannin df9e1ec42d fix delete for pollutants D90 2026-04-28 11:06:57 +02:00
Dylan Jeannin ac79fae1fb debug save db d90 2026-04-28 11:06:57 +02:00
Dylan Jeannin fe39f07981 consistency with called functions in the file 2026-04-28 11:06:57 +02:00
Dylan Jeannin b578e0c50c désactivation temporaire de undo dans la fenêtre résultat qui fait crash Pamhyr 2026-04-28 11:06:57 +02:00
Dylan Jeannin 4408a8f368 debug save BoundaryConditionsAdisTS 2026-04-28 11:06:57 +02:00
Dylan Jeannin d3e922af6e desactivation du clic sur le graph du réseau hors de l'onglet d'édition du réseau (ex. BoundaryConditions...) 2026-04-28 11:06:57 +02:00
Dylan Jeannin 8adf878584 garde le zoom sur un graph après rafraichissement des données 2026-04-28 11:06:57 +02:00
Dylan Jeannin aa6973813f debug fonction SAVE des figures, qui utilisait une méthode Matplotlib, plutôt qu'une méthode native Qt 2026-04-28 11:06:57 +02:00
Dylan Jeannin e21a64fcad zoom plus intuitif avec translation du widget pour garder une cohérence dans le zoom 2026-04-28 11:06:57 +02:00
Dylan Jeannin 8b6308d3c9 inversion du sens de zoom avec la molette sur les graphs (contrintuitif auparavant) 2026-04-28 11:06:57 +02:00
Dylan Jeannin bc3ea9c4b9 ajout automatique de l'extansion .st lorsque l'on ne le stipule pas manuellement dans l'export des tronçons 2026-04-28 11:06:57 +02:00
Dylan Jeannin 04ea55e21a can use '.' caracter and not only ',' in Shift Geometry window 2026-04-28 11:06:57 +02:00
Dylan Jeannin a68270ff67 update model + view to display only BCAdisTS related to pollutant, and not the global list, todo: reconnect add/del buttons 2026-04-28 11:06:57 +02:00
Dylan Jeannin c498ed2d96 add d50/sigma in database + load/save data in UI 2026-04-28 11:06:57 +02:00
Dylan Jeannin e6d059bc19 correction erreur identifiant bdd 2026-04-28 11:06:57 +02:00
Dylan Jeannin cc500ceccf debug model InitialConditionsAdisTSSpec 2026-04-28 11:06:57 +02:00
Dylan Jeannin 7a91969f41 refacto variable names for D90 2026-04-28 10:27:19 +02:00
Theophile Terraz 6bd3605d10 update doc links 2026-04-28 10:13:43 +02:00
Theophile Terraz 6c6da90952 debug QSO export 2026-04-28 10:09:49 +02:00
Theophile Terraz 539b63f765 update doc links 2026-04-28 10:09:24 +02:00
Dylan Jeannin e755459004 Merge branch 'scenarios' into dev_dylan 2026-04-27 16:54:52 +02:00
Dylan Jeannin a8f95e2386 fix bug when add button didnt refresh the tab list in Initial conditions AdisTS and d90 2026-04-27 16:45:36 +02:00
Dylan Jeannin 55b200a48e debug delete functionnality in InitialConditionsAdisTS 2026-04-27 16:32:41 +02:00
Dylan Jeannin 6b8d7c2df2 clean useless data 2026-04-27 15:44:57 +02:00
Dylan Jeannin eb7c4895ca fix delete for pollutants D90 2026-04-27 15:43:32 +02:00
Dylan Jeannin a060dbd461 debug save db d90 2026-04-27 12:00:39 +02:00
Dylan Jeannin 9379f7a27d consistency with called functions in the file 2026-04-27 10:07:36 +02:00
Theophile Terraz 19fedc2278 debug QSO export 2026-04-23 09:36:36 +02:00
Theophile Terraz 260efc17a9 pep8 + debug 2026-04-23 09:27:29 +02:00
Dylan Jeannin a4026d6386 désactivation temporaire de undo dans la fenêtre résultat qui fait crash Pamhyr 2026-04-22 13:45:15 +02:00
Dylan Jeannin d6f7755d12 debug save BoundaryConditionsAdisTS 2026-04-22 12:05:28 +02:00
Theophile Terraz 00b89635f3 add a warning window when opening Adis-TS results from file if wrong directory 2026-04-22 11:46:25 +02:00
Theophile Terraz f54dc07432 add warning windows in compare results 2026-04-22 11:38:51 +02:00
Theophile Terraz 3bbc55b4be add a warning window when opening Adis-TS results from file if wrong directory 2026-04-22 11:26:05 +02:00
Dylan Jeannin b58d3e005d desactivation du clic sur le graph du réseau hors de l'onglet d'édition du réseau (ex. BoundaryConditions...) 2026-04-21 16:55:04 +02:00
Dylan Jeannin 870bb41ff7 garde le zoom sur un graph après rafraichissement des données 2026-04-21 16:02:37 +02:00
Dylan Jeannin 0701531d37 debug fonction SAVE des figures, qui utilisait une méthode Matplotlib, plutôt qu'une méthode native Qt 2026-04-21 10:41:34 +02:00
Dylan Jeannin 43eb486700 zoom plus intuitif avec translation du widget pour garder une cohérence dans le zoom 2026-04-21 10:20:24 +02:00
Dylan Jeannin 82eeb9a478 inversion du sens de zoom avec la molette sur les graphs (contrintuitif auparavant) 2026-04-21 01:22:08 +02:00
Dylan Jeannin 432c263cdf ajout automatique de l'extansion .st lorsque l'on ne le stipule pas manuellement dans l'export des tronçons 2026-04-20 23:01:04 +02:00
Dylan Jeannin c2d28b0110 can use '.' caracter and not only ',' in Shift Geometry window 2026-04-16 16:44:14 +02:00
Dylan Jeannin 23361d142e update model + view to display only BCAdisTS related to pollutant, and not the global list, todo: reconnect add/del buttons 2026-04-16 15:14:28 +02:00
Dylan Jeannin 63836527c7 add d50/sigma in database + load/save data in UI 2026-04-13 13:10:50 +02:00
Dylan Jeannin 4f6e8249e0 correction erreur identifiant bdd 2026-04-08 14:33:02 +02:00
Dylan Jeannin ab2f775b95 debug model InitialConditionsAdisTSSpec 2026-04-08 12:34:05 +02:00
Theophile Terraz bb0e176956 debug 2026-04-07 11:48:36 +02:00
Theophile Terraz c0d4aced5e debug 2026-04-07 11:47:45 +02:00
Theophile Terraz 4ed865759a debug 2026-04-03 15:23:47 +02:00
Theophile Terraz 70e09d3b3a debug export csv 2026-04-03 14:42:58 +02:00
Theophile Terraz 2bcfa4d121 debug compare results with bedload 2026-04-03 14:42:58 +02:00
Theophile Terraz 5b497d61f0 add zfd in results 2026-04-03 14:41:30 +02:00
Theophile Terraz 242df7f648 start work on results buffers 2026-04-03 14:30:11 +02:00
Theophile Terraz 421e6797f6 debug export csv 2026-04-03 14:18:29 +02:00
Theophile Terraz 0886956ec8 debug compare results with bedload 2026-04-03 13:51:15 +02:00
Theophile Terraz 9670bde56f add zfd in results 2026-04-03 12:30:58 +02:00
Theophile Terraz 3277cf551b start work on results buffers 2026-04-02 11:54:55 +02:00
Theophile Terraz ad5cc831a3 debug bed elevation comparison 2026-03-26 11:02:46 +01:00
Theophile Terraz b00cca953e debug bed elevation comparison 2026-03-26 10:51:21 +01:00
Theophile Terraz 1f35020e3f update release to python3.12 2026-03-25 13:55:18 +01:00
Theophile Terraz f0994dd801 debug requirements 2026-03-25 10:21:09 +01:00
Theophile Terraz d002eebd49 debug requirements 2026-03-25 10:07:42 +01:00
Theophile Terraz e3ffac9ce0 test python3.12 2026-03-25 09:58:30 +01:00
Theophile Terraz e8a4d5eeed test debug for linux runner 2026-03-24 17:10:22 +01:00
Theophile Terraz fc090dadce test debug for linux runner 2026-03-24 16:00:49 +01:00
Theophile Terraz 25e4786484 test debug for linux runner 2026-03-24 15:55:07 +01:00
Theophile Terraz 81e85ab488 test debug for linux runner 2026-03-24 15:47:52 +01:00
Theophile Terraz 201b1099bd test debug for linux runner 2026-03-24 14:39:40 +01:00
Theophile Terraz b6054dd633 test debug for linux runner 2026-03-24 13:29:55 +01:00
Theophile Terraz 912843be25 test debug for windows runner 2026-03-24 12:04:01 +01:00
Theophile Terraz bf49a7fc87 test debug for windows runner 2026-03-24 11:47:08 +01:00
Theophile Terraz d77be00bcc force matplotlib < 3.10 to avoid a bug (removing artists) 2026-03-24 09:18:40 +01:00
Theophile Terraz ff0fa8ae8e optimize results visu 2026-03-10 11:47:13 +01:00
Theophile Terraz 92f4793181 debug open results from file 2026-03-10 11:39:27 +01:00
Theophile Terraz 5eaac204d5 add talweg in update_rk
(cherry picked from commit 674247db09)
2026-03-10 11:32:05 +01:00
Theophile Terraz 7ef41ad886 optimize results visu 2026-03-06 11:12:43 +01:00
Theophile Terraz ada396f26d debug 2026-03-05 16:46:22 +01:00
Theophile Terraz 674247db09 add talweg in update_rk 2026-03-04 11:14:05 +01:00
Theophile Terraz 5fecd29666 Claude François 2026-02-26 16:57:42 +01:00
Theophile Terraz 71e1324a0f debug open results from file 2026-02-24 17:19:59 +01:00
Theophile Terraz 07cae542b0 pep8 2026-02-24 09:18:47 +01:00
Theophile Terraz b693f67b99 debug RubarBE 2026-02-24 09:15:31 +01:00
Theophile Terraz 18a3d51d75 add adists with rubar3 + rubar3 in release 2026-02-23 10:46:05 +01:00
Theophile Terraz 118a39bd5c debug Rubar3 (from scenario branch) 2026-02-09 14:24:09 +01:00
Theophile Terraz 5357eb9735 debug geometry 2026-02-09 10:06:24 +01:00
Theophile Terraz 0946212c4b debug 2026-01-30 14:51:56 +01:00
Theophile Terraz d6ab44d18e pep8 2026-01-30 12:08:10 +01:00
Theophile Terraz 1db1a543c7 add default rubar3 in config 2026-01-30 12:00:19 +01:00
Theophile Terraz 2009e8223b debug adists view 2026-01-30 11:32:06 +01:00
Theophile Terraz bdaa38ea5c Merge branch 'master' of gitlab.com:pamhyr/pamhyr2 2026-01-13 08:58:46 +01:00
Lionel Pénard 713732b1dd Fix doc links in README 2026-01-12 11:03:56 +01:00
Theophile Terraz f053539cdd debug 2025-12-19 11:29:02 +01:00
Theophile Terraz fc6916bb3e lot of debug 2025-12-12 14:18:09 +01:00
Theophile Terraz 97c26cb4fb debug HS 2025-12-12 11:33:13 +01:00
Theophile Terraz 10c98bb96e release for Jerome 2025-12-09 14:25:38 +01:00
Theophile Terraz 3e92a0c40d debug IC 2025-12-05 16:58:54 +01:00
Theophile Terraz 7c2d9891d0 debug IC 2025-12-05 16:51:39 +01:00
Theophile Terraz 3c3ac1f1df pep8 2025-12-05 10:19:43 +01:00
Theophile Terraz 80af278a0f add label in custom export results 2025-12-05 10:18:38 +01:00
Theophile Terraz f3c461cbd9 debug AdisTS 2025-12-02 13:47:56 +01:00
Theophile Terraz f254eaee25 debug adists 2025-12-02 09:31:07 +01:00
Theophile Terraz 012408d19e translate 2025-11-28 16:25:51 +01:00
Theophile Terraz f7e563e71a prevent scenario window to open if study is not saved 2025-11-28 16:08:54 +01:00
Theophile Terraz 81c6d39c1a debug GL in resluts 2025-11-28 15:32:15 +01:00
Theophile Terraz 5adb0bdee5 debug GL in resluts 2025-11-28 15:31:07 +01:00
Theophile Terraz d682443e1d cleaning 2025-11-28 14:23:32 +01:00
Theophile Terraz 64c99d46d4 debug named points in meshed profiles 2025-11-28 14:12:06 +01:00
Theophile Terraz 0f0defb36f Revert "debug ci"
This reverts commit 1e1ee67d4b.
2025-11-27 16:10:00 +01:00
Theophile Terraz 1e1ee67d4b debug ci 2025-11-27 16:03:09 +01:00
Theophile Terraz 5bc514c565 pep8 2025-11-26 11:58:58 +01:00
Theophile Terraz c065b19ef8 debug 2025-11-26 11:46:38 +01:00
Theophile Terraz 1da3461dfe debug meshing 2025-11-26 11:16:19 +01:00
Theophile Terraz b20a4c3c3d debug meshing again... 2025-11-25 17:41:26 +01:00
Theophile Terraz d66e75c183 debug mesh AGAIN 2025-11-25 16:27:50 +01:00
Theophile Terraz 31b4c47379 debug CI 2025-11-25 13:20:57 +01:00
Theophile Terraz 71bba499e0 Revert "debug CI"
This reverts commit 7a08fa42d9.
2025-11-25 13:19:04 +01:00
Theophile Terraz 7a08fa42d9 debug CI 2025-11-25 12:03:16 +01:00
Theophile Terraz 18a008462a debug CI 2025-11-24 18:00:57 +01:00
Theophile Terraz d81da59398 debug CI 2025-11-24 17:54:33 +01:00
Theophile Terraz 3ab1eabe75 debug CI 2025-11-24 17:38:03 +01:00
Theophile Terraz cf4f860db8 debug CI 2025-11-24 17:25:51 +01:00
Theophile Terraz c68e3337ef debug CI 2025-11-24 17:09:00 +01:00
Theophile Terraz dd5eecb1e2 pep8 2025-11-24 15:18:28 +01:00
Theophile Terraz db1ae613d6 test release2 2025-11-21 16:12:53 +01:00
Theophile Terraz a800816cda test release 2025-11-21 16:01:59 +01:00
Theophile Terraz d4ef06c7c1 debug CI 2025-11-21 14:52:46 +01:00
Theophile Terraz 95d1d231c9 pep8 2025-11-21 14:07:26 +01:00
Theophile Terraz 10b278e26f Merge branch 'scenarios' of gitlab.com:pamhyr/pamhyr2 into scenarios 2025-11-21 14:05:25 +01:00
Theophile Terraz 0550eef2eb add rubarBE in release 2025-11-21 14:05:13 +01:00
parouby 73eb9919eb Merge remote-tracking branch 'origin/master' into scenarios 2025-11-21 11:23:46 +01:00
parouby 9116009b0b Geotiff: Disable add and delete for readonly mode. 2025-11-21 11:19:43 +01:00
parouby 4e4ceb5074 Geotiff: Edit: Fix readonly mode. 2025-11-21 11:14:29 +01:00
parouby d79e2ff187 Merge branch 'master' into scenarios 2025-11-21 10:55:51 +01:00
parouby d4a2594239 Wiki: Add geotiff screenshot. 2025-11-21 10:20:44 +01:00
parouby b666162bdf Merge branch 'scenario-dev-pa' into scenarios. 2025-11-20 15:44:52 +01:00
parouby d705accaed Wiki: Add scenarios screenshot. 2025-11-20 09:58:30 +01:00
Theophile Terraz d93917b081 debug internal mesher 2025-11-19 15:27:33 +01:00
Theophile Terraz ceff5f3083 debug internal mesher 2025-11-19 15:26:09 +01:00
Theophile Terraz 97762756f8 debug 2025-11-19 13:40:12 +01:00
parouby 2c49e991b4 GeoTIFF: Fix coordinates. 2025-11-19 11:46:22 +01:00
Theophile Terraz c2a8f38ef5 quick fix for AdisTS 2025-11-18 17:25:48 +01:00
parouby f8a41fce08 GeoTIFF: Add red rectangle at GeoTIFF selected. 2025-11-17 15:01:59 +01:00
parouby 624ae826eb GeoTIFF: Fix plot display where geotiff is deleted and fix update propagation. 2025-11-17 10:08:06 +01:00
parouby d47dc0687e GeoTIFF: Minor change. 2025-11-14 15:56:24 +01:00
parouby 117e5222e4 GeoTIFF: Edit: Fix event connection. 2025-11-14 15:50:24 +01:00
parouby b1c7a77f37 GeoTIFF: Fix pep8. 2025-11-14 15:18:39 +01:00
parouby 7b833390f1 Results: Add study geotiff in plot xy. 2025-11-14 15:05:00 +01:00
parouby ae08642116 GeoTIFF: Factorise draw geotiff function. 2025-11-14 15:04:31 +01:00
Theophile Terraz c1905aa7e1 debug rubarBE format 2025-11-14 11:48:02 +01:00
parouby 97ece018aa Reservoirs: Fix loading without nodes. 2025-11-14 10:01:56 +01:00
parouby 7f0102a881 GeoTIFF: Add geotiff to mainwindow tab info and fix bounds at file import. 2025-11-14 09:56:46 +01:00
parouby 786923bdbf GeoTIFF: Add missing ui files. 2025-11-13 15:08:50 +01:00
parouby deb9b2069f GeoTIFF: Integrate geotiff menu to mainwindow and fix bounds update. 2025-11-13 14:56:38 +01:00
parouby 9308a73e8e GeoTIFF: Minor change. 2025-11-13 11:47:51 +01:00
parouby 869e116ad0 GeoTIFF: Minor change. 2025-11-13 10:49:22 +01:00
parouby a2f3d22001 GeoTIFF: Add geometry and geotiff diplay next to the geotiff list. 2025-11-13 10:44:23 +01:00
parouby 2e360943b2 GeoTIFF: Switch PlotXY to display all river reaches. 2025-11-12 11:42:46 +01:00
parouby 8976f054c7 GeoTIFF: Save geotiff into study db. 2025-11-12 11:16:28 +01:00
parouby 7bce725c63 GeoTIFF: Fix pep8. 2025-11-12 10:43:20 +01:00
parouby 5c83d67865 GeoTIFF: Continue intergation. 2025-11-12 10:41:45 +01:00
parouby 6e52b1681e GeoTIFF: Continue view integration. 2025-11-11 12:26:50 +01:00
parouby f27b2cc586 GeoTIFF: Prepare model/view integration. 2025-11-10 17:10:01 +01:00
parouby 1ed5d69bf4 GeoTIFF: Prepare view integration. 2025-11-10 16:28:21 +01:00
parouby 5bb6cc40fe GeoTIFF: Add to modules list. 2025-11-10 16:04:18 +01:00
parouby 4c0a12dcf9 GeoTIFF: Integrate to River submodel. 2025-11-10 10:21:40 +01:00
parouby a308af41e0 GeoTIFF: Prepare add geotiff into pamhyr2 db. 2025-11-07 17:12:27 +01:00
parouby 4cf4015579 Results: Set import data methode default dir as results dir. 2025-11-06 09:30:29 +01:00
parouby 291b97ac9b Results: Select solver for last results also if the results path exists. 2025-11-04 16:38:35 +01:00
parouby b04e367e72 Results: Add InputDialog to select solver. 2025-11-04 16:22:11 +01:00
parouby 81d58122d6 MainWindow: Fix save callback. 2025-11-04 14:34:32 +01:00
parouby 874f592cf4 Results: Fix add data settings. 2025-11-04 14:18:00 +01:00
parouby 9b0bdd1e63 Results: Fix plot add data 'Q(t)'. 2025-11-04 10:15:37 +01:00
parouby 14549330b9 Results: Add additional data to SQL study save. 2025-11-03 16:55:36 +01:00
parouby 2487bec6d6 Results: Minor change. 2025-11-03 15:04:05 +01:00
parouby 4e1acfecdc Results: Refacto read csv. 2025-11-03 14:55:42 +01:00
parouby c63c776989 MainWindow: Add message box at results opening error. 2025-11-03 10:03:49 +01:00
parouby 44a8be6be3 WaitingDialog: Minor change. 2025-10-31 17:27:47 +01:00
parouby a5a64f2080 MainWindow: Minor change and fix. 2025-10-31 15:41:25 +01:00
parouby 16ee5a90e4 Results: Fix update table creation. 2025-10-31 15:05:38 +01:00
parouby 7ca6e69526 Pamhyr2: Add save action (ctrl+s) in each pamhyr window. 2025-10-31 14:43:01 +01:00
Theophile Terraz a31e2127e7 debug old .INI file read 2025-10-23 16:32:04 +02:00
parouby a29df8f904 Network: Center on previous size. 2025-10-21 17:28:16 +02:00
parouby 97ebf9324a Merge branch 'master' of gitlab.com:pamhyr/pamhyr2 2025-10-21 15:42:01 +02:00
parouby 0112ad63d9 Network: Resize network zone. 2025-10-21 15:38:12 +02:00
Theophile Terraz bcbb440ad4 debug import friction 2025-10-21 15:11:28 +02:00
344 changed files with 11343 additions and 2413 deletions

No files matched your search

+46 -8
View File
@@ -38,6 +38,7 @@ variables:
variables:
MAGE_8_VERSION: "permalink/latest"
ADISTS_VERSION: "permalink/latest"
RUBAR_VERSION: "permalink/latest"
dl-mage8-doc:
stage: downloads
@@ -111,6 +112,36 @@ dl-adists-windows:
paths:
- adists-windows/adists.exe
dl-rubar-linux:
stage: downloads
tags:
- linux
rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
script:
- mkdir -p rubar-linux
- cd rubar-linux
- curl -L -o rubar.tgz https://forge.inrae.fr/river-hydraulics/rubarbe/-/releases/$RUBAR_VERSION/downloads/packages/rubar_linux.tgz
- tar xf rubar.tgz
artifacts:
paths:
- rubar-linux/rubarbe
dl-rubar-windows:
stage: downloads
tags:
- linux
rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
script:
- mkdir -p rubar-windows
- cd rubar-windows
- curl -L -o rubar.tgz https://forge.inrae.fr/river-hydraulics/rubarbe/-/releases/$RUBAR_VERSION/downloads/packages/rubar_windows.tgz
- tar xf rubar.tgz
artifacts:
paths:
- rubar-windows/rubarbe.exe
#############
# CONFIGURE #
#############
@@ -149,13 +180,13 @@ unittest:
- job: set-version
artifacts: true
script:
- python3 -m venv venv
- python3.12 -m venv venv
- . venv/bin/activate
- pip3 install -U pip
- pip3 install -r ./full-requirements.txt
- pip3 install -U -r ./full-requirements.txt
- cd src
- python3 -m unittest discover -t .
- python3.12 -m unittest discover -t .
test-pep8:
stage: test
@@ -167,7 +198,7 @@ test-pep8:
- job: unittest
script:
# Setup virtual env
- python3 -m venv venv
- python3.12 -m venv venv
- . venv/bin/activate
- pip3 install -U pip
- pip3 install -r ./requirements.txt
@@ -245,7 +276,7 @@ build-developers-doc:
- ./build.sh
# Create html documentation
- cd ../../src
- python3 -m venv doc-venv
- python3.12 -m venv doc-venv
- . doc-venv/bin/activate
- pip3 install -U pip
- pip3 install -r ../full-requirements.txt
@@ -273,6 +304,8 @@ build-linux:
needs:
- job: dl-adists-linux
artifacts: true
- job: dl-rubar-linux
artifacts: true
- job: dl-mage8-linux
artifacts: true
- job: dl-mage8-doc
@@ -293,13 +326,13 @@ build-linux:
- mkdir -p linux
- cd linux
# Setup virtual env
- python3 -m venv linux-venv
- python3.12 -m venv linux-venv
- . linux-venv/bin/activate
- pip3 install -U pip
- pip3 install -r ../requirements.txt
- pip3 install -U -r ../requirements.txt
# Run Pyinstaller
- pyinstaller -y $HIDDEN_IMPORTS --paths linux-venv/lib/python3.8/site-packages ../src/pamhyr.py
- pyinstaller -y $HIDDEN_IMPORTS --paths linux-venv/lib/python3.12/site-packages ../src/pamhyr.py
# Create directory
- mkdir -p pamhyr
- mkdir -p pamhyr/_internal
@@ -314,6 +347,9 @@ build-linux:
# Copy adists
- mkdir -p pamhyr/adists
- cp -v ../adists-linux/* pamhyr/adists/
# Copy rubar
- mkdir -p pamhyr/rubar
- cp -v ../rubar-linux/* pamhyr/rubar/
# Copy Pamhyr
- cp -r dist/pamhyr/* pamhyr/
# Pamhyr script to force x11
@@ -379,6 +415,8 @@ build-windows:
artifacts: true
- job: dl-adists-windows
artifacts: true
- job: dl-rubar-windows
artifacts: true
- job: dl-mage8-doc
artifacts: true
- job: set-version
@@ -600,7 +638,7 @@ shadow-release:
- job: pkg-hash
artifacts: true
rules:
- if: $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TAG
- if: $CI_COMMIT_TAG && $CI_COMMIT_TAG !~ /^v/
artifacts:
paths:
- linux/pamhyr-gnulinux.tar.xz
@@ -634,7 +672,7 @@ tag-release:
- job: pkg-hash
artifacts: true
rules:
- if: $CI_COMMIT_BRANCH == 'master' && $CI_COMMIT_TAG
- if: $CI_COMMIT_TAG =~ /^v/
artifacts:
paths:
- linux/pamhyr-gnulinux.tar.xz
+2 -1
View File
@@ -1,3 +1,4 @@
Sylvain COULIBALY, INRAE, 2020 - 2022
Théophile TERRAZ, INRAE, 2022 - 2024
Pierre-Antoine ROUBY, INRAE, 2023 - 2025
Pierre-Antoine ROUBY, INRAE, 2023 - 2026
Dylan JEANNIN, INRAE, 2026
+8 -8
View File
@@ -3,7 +3,7 @@
Pamhyr is a free and open source graphical user interface for 1D hydro-sedimentary
modelling of rivers.
![logo](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/raw/master/src/View/ui/ressources/Pamhyr2_logo.png)
![logo](https://gitlab.com/pamhyr/pamhyr2/-/raw/master/src/View/ui/ressources/Pamhyr2_logo.png)
## Features
@@ -21,9 +21,9 @@ modelling of rivers.
+ Create and edit study alternative scenario tree
Let see the
[documentation](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home)
([:fr:](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home-fr),
[:gb:](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home-en))
[documentation](https://gitlab.com/pamhyr/pamhyr2/-/wikis/home)
([:fr:](https://gitlab.com/pamhyr/pamhyr2/-/wikis/home-fr),
[:gb:](https://gitlab.com/pamhyr/pamhyr2/-/wikis/home-en))
for more details.
## Install
@@ -31,11 +31,11 @@ for more details.
### GNU/Linux
See documentation:
- [French :fr:](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home/fr/Install%20on%20GNULinux)
- [English :gb:](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home/en/Install%20on%20GNULinux)
- [French :fr:](https://gitlab.com/pamhyr/pamhyr2/-/wikis/home/fr/Install%20on%20GNULinux)
- [English :gb:](https://gitlab.com/pamhyr/pamhyr2/-/wikis/home/en/Install%20on%20GNULinux)
### Windows
See documentation:
- [French :fr:](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home/fr/Install%20on%20Windows)
- [English :gb:](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home/en/Install%20on%20Windows)
- [French :fr:](https://gitlab.com/pamhyr/pamhyr2/-/wikis/home/fr/Install%20on%20Windows)
- [English :gb:](https://gitlab.com/pamhyr/pamhyr2/-/wikis/home/en/Install%20on%20Windows)
Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

+6 -6
View File
@@ -157,12 +157,12 @@
%%
%% FIXME: Delete me for the first realease
\usepackage{draftwatermark}
\SetWatermarkLightness{0.8}
\SetWatermarkAngle{25}
\SetWatermarkScale{3}
\SetWatermarkFontSize{1cm}
\SetWatermarkText{Work in progress}
%% \usepackage{draftwatermark}
%% \SetWatermarkLightness{0.8}
%% \SetWatermarkAngle{25}
%% \SetWatermarkScale{3}
%% \SetWatermarkFontSize{1cm}
%% \SetWatermarkText{Work in progress}
%% Icons
+3 -3
View File
@@ -1,10 +1,10 @@
PyQt5==5.15.4
PyQt5==5.15.11
PyQt5-Qt5==5.15.2
PyQt5-sip==12.12.2
PyQt5-sip==12.18.0
PyQtWebEngine==5.15.6
QScintilla>=2.14.1
pyqtgraph>=0.12.1
matplotlib>=3.7.1
matplotlib==3.8.3
numpy>=1.24.2
colorama>=0.4.3
pyinstaller>=5.11.0
+1 -1
View File
@@ -20,4 +20,4 @@
"python-pyqtgraph" "python-qscintilla"
"python-numpy@1" "python-shapely" "python-pyshp"
"python-matplotlib" "python-colorama"
"python-rasterio"))
"python-rasterio" "python-psutil"))
+4
View File
@@ -46,6 +46,10 @@ copy /y ..\mage8-windows\mage_extraire.exe pamhyr\mage8\
copy /y ..\mage8-windows\mailleurTT.exe pamhyr\mage8\
copy /y ..\mage8-windows\libbief.dll pamhyr\mage8\
rem rubar
mkdir pamhyr\rubar
copy /y ..\rubar-windows\rubarbe.exe pamhyr\rubar\
rem adists
mkdir pamhyr\adists
copy /y ..\adists-windows\adists.exe pamhyr\adists\
+4 -3
View File
@@ -1,10 +1,10 @@
PyQt5==5.15.4
PyQt5==5.15.11
PyQt5-Qt5==5.15.2
PyQt5-sip==12.12.2
PyQt5-sip==12.18.0
#PyQtWebEngine==5.15.6
QScintilla>=2.14.1
pyqtgraph>=0.12.1
matplotlib>=3.7.1
matplotlib==3.8.3
numpy>=1.24.2
colorama>=0.4.3
pyinstaller>=5.11.0
@@ -14,3 +14,4 @@ platformdirs>=4.2.0
pyshp>=2.3.1
rasterio==1.3.11
#fortranformat==2.0.3
psutil>=7.2.2
+1 -1
View File
@@ -1,5 +1,5 @@
# Adists.py -- Pamhyr study checkers
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# Checker.py -- Pamhyr abstract checker class
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# Mage.py -- Pamhyr MAGE checkers
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# Study.py -- Pamhyr study checkers
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# AMeshingTool.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+90 -72
View File
@@ -1,5 +1,5 @@
# Internal.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -40,20 +40,24 @@ class InternalMeshing(AMeshingTool):
step: float = 50,
limites=[-1, -1],
linear: bool = True):
if reach is None or len(reach.profiles) == 0:
return reach
if limites[0] > limites[1]:
lim = limites[1]
limites[1] = limites[0]
limites[0] = lim
elif limites[0] == limites[1]:
return reach
# pre process
# we never modify original profiles, we work on copies
m_profiles = self.st_to_m(reach, limites)
new_profiles = self.interpolate_transversal_step(m_profiles,
step)
profiles = self.get_profiles(reach, limites)
if profiles is None:
return []
for p in profiles:
if len(p) < 1:
return []
guide_list = self.get_guide_list(reach, profiles)
if guide_list is None:
return []
# we never modify original profiles, we work on the copies
m_profiles = self.st_to_m(profiles, guide_list)
new_profiles = self.interpolate_transversal_step(m_profiles, step)
for new_profiles2 in new_profiles:
for p in new_profiles2:
@@ -61,52 +65,32 @@ class InternalMeshing(AMeshingTool):
return new_profiles
def st_to_m(self, reach, limites):
gl = reach.compute_guidelines()
profiles = [reach.profile(i).copy()
for i in range(limites[0], limites[1]+1)
]
# we make sure that the lines are in the left-to-right order
guide_list = [
x.name
for x in profiles[0].named_points()
if x.name in gl[0]
]
gl1 = [""] + guide_list
gl2 = guide_list + [""]
max_values = [0] * (len(guide_list) + 1)
max_values_index = [0] * (len(guide_list) + 1)
def st_to_m(self, profiles, guide_list):
guide_list = ["un"] + guide_list + ["np"]
max_values = [0] * (len(guide_list) - 1)
max_values_index = [0] * (len(guide_list) - 1)
# we work between each couple of guidelines
for j, p in enumerate(profiles):
index1 = 0
index2 = p.named_point_index(guide_list[0])
if index2 - index1 > max_values[0]:
max_values[0] = index2 - index1
max_values_index[0] = j
for i in range(len(guide_list) - 1):
index1 = p.named_point_index(guide_list[i])
index2 = p.named_point_index(guide_list[i+1])
if index2 - index1 > max_values[i+1]:
max_values[i+1] = index2 - index1
max_values_index[i+1] = j
index1 = p.named_point_index(guide_list[-1])
index2 = len(p) - 1
if index2 - index1 > max_values[-1]:
max_values[-1] = index2 - index1
max_values_index[-1] = j
if index2 - index1 > max_values[i]:
max_values[i] = index2 - index1
max_values_index[i] = j
for i in range(len(max_values)):
for isect in range(max_values_index[i], len(profiles)-1):
self.compl_sect(profiles[isect],
profiles[isect+1],
gl1[i], gl2[i])
guide_list[i],
guide_list[i+1])
for isect in reversed(range(0, max_values_index[i])):
self.compl_sect(profiles[isect+1],
profiles[isect],
gl1[i], gl2[i])
guide_list[i],
guide_list[i+1])
return profiles
def interpolate_transversal_step(self,
@@ -146,6 +130,7 @@ class InternalMeshing(AMeshingTool):
p.name = f'interpol{p.rk}'
new_profiles2.append(p)
new_profiles.append(new_profiles2)
return new_profiles
def compl_sect(self, sect1, sect2, tag1, tag2):
@@ -156,26 +141,17 @@ class InternalMeshing(AMeshingTool):
# len1 and 2: number of intervals
# len1: target len
if tag1 == '': # left end point
start1 = 0
start2 = 0
else:
start1 = sect1.named_point_index(tag1)
start2 = sect2.named_point_index(tag1)
start1 = sect1.named_point_index(tag1)
start2 = sect2.named_point_index(tag1)
if tag2 == '': # right end point
end1 = sect1.nb_points-1
end2 = sect2.nb_points-1
else:
end1 = sect1.named_point_index(tag2)
end2 = sect2.named_point_index(tag2)
end1 = sect1.named_point_index(tag2)
end2 = sect2.named_point_index(tag2)
len1 = end1 - start1
len2 = end2 - start2
if len1 < len2:
self.compl_sect(sect2, sect1, start2, start1,
len2, len1, tag1, tag2)
self.compl_sect(sect2, sect1, tag1, tag2)
return
elif len1 == len2:
return
@@ -190,27 +166,25 @@ class InternalMeshing(AMeshingTool):
for i in range(len1):
ltot1 += sect1.point(start1+i).dist(sect1.point(start1+i+1))
alpha.append(ltot1)
alpha = list(map(lambda x: x/ltot1, alpha)) # target ratios
for i in range(len2):
ltot2 += sect2.point(start2+i).dist(sect2.point(start2+i+1))
beta.append(ltot2)
beta = list(map(lambda x: x/ltot2, beta)) # current ratios
for i in range(len1 - len2):
beta.append(1.0)
beta.append(0.0) # beta[-1]
if len2 < 1 or ltot2 < 0.0001:
# unique point (copy len1 times)
# we are at an edge of the profile
for i in range(len1-len2):
p = sect2.point(start2).copy()
sect2.insert_point(start2, p)
if tag1 == '': # left end point
sect2.point(start2).name = ''
if tag2 == '': # left end point
sect2.point(start2+1).name = ''
len2 += 1
elif ltot1 < 0.0001:
sect2.add_npoints(len1-len2)
len2 = len1
else: # regular case
alpha = list(map(lambda x: x/ltot1, alpha)) # target ratios
beta = list(map(lambda x: x/ltot2, beta)) # current ratios
for i in range(len1 - len2):
beta.append(1.0)
beta.append(0.0) # beta[-1]
# loop on the points to insert
for k in range(len1-len2):
trouve = False
@@ -242,7 +216,7 @@ class InternalMeshing(AMeshingTool):
ratio = (alpha[j0] - beta[j0-1]) \
/ (beta[j0] - beta[j0-1])
if ratio < 0.0:
print(f"ratio négatif {ratio}")
logger.warning(f"ratio négatif {ratio}")
# on double le point a gauche
p = sect2.point(start2+j0-1).copy()
sect2.insert_point(start2+j0-1, p)
@@ -269,8 +243,11 @@ class InternalMeshing(AMeshingTool):
p = sect2.point(start2+len2).copy()
sect2.insert_point(start2+len2, p)
sect2.point(start2+len2).name = ''
sect2.point(start2).name = tag1
sect2.point(start2+len2).name = tag2
if tag1 != "un":
sect2.point(start2).name = tag1
if tag2 != "np":
sect2.point(start2+len2).name = tag2
sect2.modified()
def update_rk(self, reach, begin_rk, end_rk,
@@ -304,6 +281,8 @@ class InternalMeshing(AMeshingTool):
sgn = -1.0
else:
sgn = old_orientation
if abs(sgn) < 0.5:
sgn = 1.0
new_rk = [0.0]*nprof
new_rk[origin] = origin_value
@@ -344,3 +323,42 @@ class InternalMeshing(AMeshingTool):
return new_rk, new_end_rk, new_begin_rk
else:
return new_rk, new_begin_rk, new_end_rk
def get_guide_list(self, reach, profiles):
gl = reach.compute_guidelines()
# we make sure that the lines are in the left-to-right order
guide_list = [
[
x.name
for x in p.named_points()
if x.name in gl[0]
]
for p in profiles]
# we make sure the lines never cross
for gl in guide_list:
for i in range(len(guide_list[0])):
if gl[i] != guide_list[0][i]:
return None
return guide_list[0]
def get_profiles(self, reach, limites):
if reach is None or len(reach.profiles) == 0:
return None
if limites[0] > limites[1]:
lim = limites[1]
limites[1] = limites[0]
limites[0] = lim
elif limites[0] == limites[1]:
return None
profiles = [reach.profile(i).copy()
for i in range(limites[0], limites[1]+1)
]
return profiles
+1 -1
View File
@@ -1,5 +1,5 @@
# Mage.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# __init__.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# test_Model.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1,5 +1,5 @@
# BoundaryCondition.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -232,6 +232,8 @@ class BoundaryCondition(SQLSubModel):
type TEXT NOT NULL,
tab TEXT NOT NULL,
node INTEGER,
d50 REAL DEFAULT 0.002,
sigma REAL DEFAULT 1,
{Scenario.create_db_add_scenario()},
{Scenario.create_db_add_scenario_fk()},
FOREIGN KEY(node) REFERENCES river_node(pamhyr_id),
@@ -258,6 +260,17 @@ class BoundaryCondition(SQLSubModel):
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
)
if major == "0" and int(minor) <= 2:
if int(release) < 4:
execute(
"ALTER TABLE boundary_condition " +
"ADD COLUMN d50 REAL DEFAULT 0.002"
)
execute(
"ALTER TABLE boundary_condition " +
"ADD COLUMN sigma REAL DEFAULT 1"
)
return cls._update_submodel(execute, version, data)
@classmethod
@@ -316,7 +329,8 @@ class BoundaryCondition(SQLSubModel):
return new
table = execute(
"SELECT pamhyr_id, deleted, name, type, node, scenario " +
"SELECT pamhyr_id, deleted, name, type, node, d50, sigma, " +
"scenario " +
"FROM boundary_condition " +
f"WHERE tab = '{tab}' " +
f"AND scenario = {scenario.id} " +
@@ -331,6 +345,8 @@ class BoundaryCondition(SQLSubModel):
name = next(it)
t = next(it)
node = next(it)
d50 = next(it)
sigma = next(it)
owner_scenario = next(it)
ctor = cls._get_ctor_from_type(t)
@@ -340,9 +356,14 @@ class BoundaryCondition(SQLSubModel):
status=data['status'],
owner_scenario=owner_scenario
)
if deleted:
bc.set_as_deleted()
if t == "SL":
bc.d50 = d50
bc.sigma = sigma
bc.node = None
if node != -1:
bc.node = next(filter(lambda n: n.id == node, nodes), None)
@@ -375,15 +396,22 @@ class BoundaryCondition(SQLSubModel):
if self._node is not None:
node = self._node.id
d50 = 0.002
sigma = 1
if self._type == "SL":
d50 = self._d50
sigma = self._sigma
execute(
"INSERT INTO " +
"boundary_condition(" +
"pamhyr_id, deleted, name, type, tab, node, scenario" +
"pamhyr_id, deleted, name, type, tab, node, d50, sigma, scenario" +
") " +
"VALUES (" +
f"{self._pamhyr_id}, {self._db_format(self.is_deleted())}, " +
f"'{self._db_format(self._name)}', " +
f"'{self._db_format(self._type)}', '{tab}', {node}, " +
f"{d50}, {sigma}, " +
f"{self._status.scenario_id}" +
")"
)
@@ -468,6 +496,24 @@ class BoundaryCondition(SQLSubModel):
def has_node(self):
return self._node is not None
@property
def d50(self):
return self._d50
@d50.setter
def d50(self, value):
self._d50 = float(value)
self.modified()
@property
def sigma(self):
return self._sigma
@sigma.setter
def sigma(self, value):
self._sigma = float(value)
self.modified()
@property
def header(self):
return self._header.copy()
@@ -1,5 +1,5 @@
# BoundaryConditionList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1,5 +1,5 @@
# BoundaryConditionTypes.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1,5 +1,5 @@
# BoundaryConditionsAdisTS.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -70,9 +70,8 @@ class Data(SQLSubModel):
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
created = False
if major == "0" and int(minor) <= 1:
if int(release) < 7:
if major == "0" and minor == "0":
if int(release) < 11:
cls._db_create(execute)
created = True
@@ -143,8 +142,9 @@ class Data(SQLSubModel):
table = execute(
"SELECT pamhyr_id, deleted, data0, data1, scenario FROM " +
"boundary_condition_data_adists " +
f"WHERE bca = {bca.id} " +
f"AND scenario = {scenario.id}"
f"WHERE scenario = {scenario.id} " +
# f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) " +
f"AND bca = {bca.id}"
)
if table is not None:
@@ -187,8 +187,9 @@ class Data(SQLSubModel):
execute(
"INSERT INTO " +
"boundary_condition_data_adists(" +
"pamhyr_id, data0, data1, bca, scenario) " +
f"VALUES ({self.id}, '{data0}', {data1}, {bca.id}, " +
"pamhyr_id, deleted, data0, data1, bca, scenario) " +
f"VALUES ({self.id}, {self._db_format(self.is_deleted())}, " +
f"'{data0}', {data1}, {bca.id}, " +
f"{self._status.scenario_id})"
)
@@ -247,15 +248,13 @@ class BoundaryConditionAdisTS(SQLSubModel):
major, minor, release = version.strip().split(".")
created = False
if major == "0" and int(minor) <= 1:
if int(release) < 7:
if major == "0" and int(minor) < 2:
if cls.is_table_exists(execute, "boundary_condition_adists"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
cls._db_update_to_0_2_0(execute, data)
if not created:
return cls._update_submodel(execute, version, data)
@@ -300,6 +299,14 @@ class BoundaryConditionAdisTS(SQLSubModel):
if pol_id == -1:
continue
if pol_id not in pid_pol:
# ⚠️ cas important : probablement déjà migré
logger.warning(
f"pol_id {pol_id} not in pid_pol " +
"→ probably already migrated"
)
continue
execute(
f"UPDATE boundary_condition_adists " +
f"SET pollutant = {pid_pol[pol_id]} " +
@@ -312,17 +319,21 @@ class BoundaryConditionAdisTS(SQLSubModel):
status = data['status']
nodes = data['nodes']
scenario = data["scenario"]
pollutant = data.get("pollutant")
loaded = data['loaded_pid']
if scenario is None:
return new
table = execute(
"SELECT pamhyr_id, deleted, pollutant, type, node, scenario " +
sql = (
"SELECT pamhyr_id, deleted, pollutant, type, node, scenario "
"FROM boundary_condition_adists " +
f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
f"WHERE scenario = {scenario.id} "
)
if pollutant is not None:
sql += f"AND pollutant = {pollutant.id} "
table = execute(sql)
if table is not None:
for row in table:
@@ -347,7 +358,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
bc.type = bc_type
bc.node = None
if row[3] != -1:
if node != -1:
tmp = next(
filter(
lambda n: n.id == node, nodes
@@ -426,7 +437,14 @@ class BoundaryConditionAdisTS(SQLSubModel):
d._data_traversal(predicate, modifier, data)
def __len__(self):
return len(self._data)
return len(
list(
filter(
lambda el: el is not None and not el.is_deleted(),
self._data
)
)
)
@classmethod
def time_convert(cls, data):
@@ -451,7 +469,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
@node.setter
def node(self, node):
self._node = node
self._status.modified()
self.modified()
@property
def header(self):
@@ -460,7 +478,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
@header.setter
def header(self, header):
self._header = header
self._status.modified()
self.modified()
@property
def pollutant(self):
@@ -469,7 +487,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
@pollutant.setter
def pollutant(self, pollutant):
self._pollutant = pollutant
self._status.modified()
self.modified()
@property
def type(self):
@@ -478,11 +496,16 @@ class BoundaryConditionAdisTS(SQLSubModel):
@type.setter
def type(self, type):
self._type = type
self._status.modified()
self.modified()
@property
def data(self):
return self._data.copy()
return list(
filter(
lambda el: el is not None and not el.is_deleted(),
self._data
)
)
@property
def _default_0(self):
@@ -511,33 +534,36 @@ class BoundaryConditionAdisTS(SQLSubModel):
return (new_0, new_1)
def add(self, index: int):
value = (self._default_0, self._default_1)
value = Data(
self._default_0, self._default_1,
status=self._status
)
self._data.insert(index, value)
self._status.modified()
self.modified()
return value
def insert(self, index: int, value):
self._data.insert(index, value)
self._status.modified()
self.modified()
def delete_i(self, indexes):
self._data = list(
list(
map(
lambda e: e[1],
lambda e: e[1].set_as_deleted(),
filter(
lambda e: e[0] not in indexes,
lambda e: e[0] in indexes,
enumerate(self.data)
)
)
)
self._status.modified()
self.modified()
def sort(self, _reverse=False, key=None):
if key is None:
self._data.sort(reverse=_reverse)
else:
self._data.sort(reverse=_reverse, key=key)
self._status.modified()
self.modified()
def index(self, bc):
self._data.index(bc)
@@ -552,10 +578,10 @@ class BoundaryConditionAdisTS(SQLSubModel):
return lst
def _set_i_c_v(self, index, column, value):
v = list(self._data[index])
v = self._data[index]
v[column] = self._types[column](value)
self._data[index] = tuple(v)
self._status.modified()
self._data[index] = v
self.modified()
def set_i_0(self, index: int, value):
self._set_i_c_v(index, 0, value)
@@ -1,5 +1,5 @@
# BoundaryConditionsAdisTSList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -38,9 +38,13 @@ class BoundaryConditionsAdisTSList(PamhyrModelList):
if data is None:
data = {}
new._lst = BoundaryConditionAdisTS._db_load(
execute, data
)
previous_pollutant = data.get("pollutant")
data.pop("pollutant", None)
new._lst = BoundaryConditionAdisTS._db_load(execute, data)
if previous_pollutant is not None:
data["pollutant"] = previous_pollutant
return new
+5 -7
View File
@@ -1,5 +1,5 @@
# D90AdisTS.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -73,15 +73,13 @@ class D90AdisTS(SQLSubModel):
major, minor, release = version.strip().split(".")
created = False
if major == "0" and int(minor) <= 1:
if int(release) < 6:
if major == "0" and int(minor) < 2:
if cls.is_table_exists(execute, "d90_adists"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
cls._db_update_to_0_2_0(execute, data)
if not created:
return cls._update_submodel(execute, version, data)
+1 -1
View File
@@ -1,5 +1,5 @@
# D90AdisTSList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+16 -16
View File
@@ -1,5 +1,5 @@
# D90AdisTSSpec.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -70,16 +70,12 @@ class D90AdisTSSpec(SQLSubModel):
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
created = False
if major == 0 and minor < 1:
if int(release) < 6:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
if cls.is_table_exists(execute, "d90_spec"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
return True
@@ -87,6 +83,7 @@ class D90AdisTSSpec(SQLSubModel):
def _db_update_to_0_2_0(cls, execute, data):
table = "d90_spec"
table_new = "d90_adists_spec"
reachs = data['id2pid']['river_reach']
cls.update_db_add_pamhyr_id(execute, table, data)
Scenario.update_db_add_scenario(execute, table)
@@ -95,8 +92,10 @@ class D90AdisTSSpec(SQLSubModel):
execute(
f"INSERT INTO {table_new}_tmp " +
"(pamhyr_id, name, d90, enabled, scenario) " +
"SELECT pamhyr_id, name, d90, enabled, scenario " +
"(pamhyr_id, d90_default, name, reach, " +
" start_rk, end_rk, d90, enabled, scenario) " +
"SELECT pamhyr_id, d90_default, name, reach, " +
" start_rk, end_rk, d90, enabled, scenario " +
f"FROM {table}"
)
@@ -104,12 +103,13 @@ class D90AdisTSSpec(SQLSubModel):
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}")
cls._db_update_to_0_2_0_set_d90_pid(execute, data)
cls._db_update_to_0_2_0_set_reach_pid(execute, table_new, reachs)
@classmethod
def _db_update_to_0_2_0_set_d90_pid(cls, execute, data):
pid_d90 = data["id2pid"]["d90_adists"]
els = execute(
f"SELECT pamhyr_id, d90 FROM d90_adists_spec"
f"SELECT pamhyr_id, d90_default FROM d90_adists_spec"
)
for row in els:
@@ -121,8 +121,8 @@ class D90AdisTSSpec(SQLSubModel):
continue
execute(
f"UPDATE d90_adists_spec" +
f"SET d90 = {pid_d90[d90_id]} " +
f"UPDATE d90_adists_spec " +
f"SET d90_default = {pid_d90[d90_id]} " +
f"WHERE pamhyr_id = {pid}"
)
@@ -167,7 +167,7 @@ class D90AdisTSSpec(SQLSubModel):
owner_scenario=owner_scenario
)
if deleted:
new_spec.is_deleted()
new_spec.set_as_deleted()
new_spec.reach = reach
new_spec.start_rk = start_rk
@@ -196,12 +196,12 @@ class D90AdisTSSpec(SQLSubModel):
"d90_default, name, reach, " +
"start_rk, end_rk, d90, enabled, scenario) " +
"VALUES (" +
f"{self.id}, {self._db_format(self.is_deleted())}" +
f"{self.id}, {self._db_format(self.is_deleted())}, " +
f"{d90_default}, " +
f"'{self._db_format(self._name_section)}', " +
f"{self._reach}, " +
f"{self._start_rk}, {self._end_rk}, " +
f"{self._d90}, {self._enabled}" +
f"{self._d90}, {self._enabled}, " +
f"{self._status.scenario_id}" +
")"
)
+15 -17
View File
@@ -1,5 +1,5 @@
# DIFAdisTS.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -79,15 +79,13 @@ class DIFAdisTS(SQLSubModel):
major, minor, release = version.strip().split(".")
created = False
if major == "0" and int(minor) <= 1:
if int(release) < 6:
if major == "0" and int(minor) < 2:
if cls.is_table_exists(execute, "dif_adists"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
cls._db_update_to_0_2_0(execute, data)
if not created:
return cls._update_submodel(execute, version, data)
@@ -142,24 +140,24 @@ class DIFAdisTS(SQLSubModel):
enabled = (next(it) == 1)
owner_scenario = next(it)
dif = cls(
DIF = cls(
id=pid,
name=name,
status=status,
owner_scenario=owner_scenario,
)
dif.method = method
dif.dif = dif
dif.b = b
dif.c = c
dif.enabled = enabled
DIF.method = method
DIF.dif = dif
DIF.b = b
DIF.c = c
DIF.enabled = enabled
data['dif_default_id'] = pid
dif._data = DIFAdisTSSpec._db_load(execute, data)
DIF._data = DIFAdisTSSpec._db_load(execute, data)
loaded.add(pid)
new.append(dif)
new.append(DIF)
data["scenario"] = scenario.parent
new += cls._db_load(execute, data)
@@ -190,7 +188,7 @@ class DIFAdisTS(SQLSubModel):
b = self.b
c = -1.
if self.dif is not None:
if self.c is not None:
c = self.c
sql = (
@@ -201,7 +199,7 @@ class DIFAdisTS(SQLSubModel):
"VALUES (" +
f"{self.id}, '{self._db_format(self._name)}', " +
f"'{self._db_format(self._method)}', " +
f"{dif.id}, {b}, {c}, {self._enabled}, " +
f"{dif}, {b}, {c}, {self._enabled}, " +
f"{self._status.scenario_id}" +
")"
)
+1 -1
View File
@@ -1,5 +1,5 @@
# DIFAdisTSList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+14 -21
View File
@@ -1,5 +1,5 @@
# DIFAdisTSSpec.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -33,16 +33,14 @@ class DIFAdisTSSpec(SQLSubModel):
_id_cnt = 0
def __init__(self, id: int = -1, method: str = "",
status=None):
super(DIFAdisTSSpec, self).__init__()
status=None, owner_scenario=-1):
super(DIFAdisTSSpec, self).__init__(
id=id, status=status,
owner_scenario=owner_scenario
)
self._status = status
if id == -1:
self.id = DIFAdisTSSpec._id_cnt
else:
self.id = id
self._method = method
self._reach = None
self._start_rk = None
@@ -52,8 +50,6 @@ class DIFAdisTSSpec(SQLSubModel):
self._c = None
self._enabled = True
DIFAdisTSSpec._id_cnt = max(DIFAdisTSSpec._id_cnt + 1, self.id)
@classmethod
def _db_create(cls, execute, ext=""):
execute(f"""
@@ -81,16 +77,12 @@ class DIFAdisTSSpec(SQLSubModel):
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
created = False
if major == 0 and minor < 1:
if int(release) < 6:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
if cls.is_table_exists(execute, "dif_spec"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
return True
@@ -195,7 +187,7 @@ class DIFAdisTSSpec(SQLSubModel):
new_spec.c = c
new_spec.enabled = enabled
loaded.add(pid)
loaded.add(id)
new.append(new_spec)
data["scenario"] = scenario.parent
@@ -210,22 +202,23 @@ class DIFAdisTSSpec(SQLSubModel):
dif_default = data['dif_default_id']
execute(
sql = (
"INSERT INTO " +
"dif_adists_spec(pamhyr_id, deleted, " +
"dif_default, method, reach, " +
"start_rk, end_rk, dif, b, c, enabled, scenario) " +
"VALUES (" +
f"{self.id}, {self._db_format(self.is_deleted())}" +
f"{self.id}, {self._db_format(self.is_deleted())}, " +
f"{dif_default}, " +
f"'{self._db_format(self._method)}', " +
f"{self._reach}, " +
f"{self._start_rk}, {self._end_rk}, " +
f"{self._dif}, {self._b}, {self._c}, " +
f"{self._enabled}" +
f"{self._enabled}, " +
f"{self._status.scenario_id}" +
")"
)
execute(sql)
return True
+241
View File
@@ -0,0 +1,241 @@
# Distribution.py -- Pamhyr
# Copyright (C) 2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
import struct
import logging
import itertools
import numpy as np
from tools import logger_exception
from Model.Except import NotImplementedMethodeError
from Model.Tools.PamhyrDB import SQLSubModel
from Model.Scenario import Scenario
logger = logging.getLogger()
class Distribution(SQLSubModel):
_sub_classes = []
def __init__(self, id: int = -1,
name: str = "", script: str = "",
status=None):
super(Distribution, self).__init__(
id=id, status=status,
owner_scenario=0
)
self._name = name
self._type = "generic"
self._script = script
self._labels = []
self._default_values = []
@property
def name(self):
return self._name
@property
def labels(self):
return self._labels
@property
def default_values(self):
return self._default_values
@classmethod
def _db_create(cls, execute, ext=""):
execute(f"""
CREATE TABLE ensemble_distribution{ext} (
{cls.create_db_add_pamhyr_id()},
deleted BOOLEAN NOT NULL DEFAULT FALSE,
name TEXT NOT NULL,
script TEXT NOT NULL,
PRIMARY KEY(pamhyr_id)
)
""")
if ext == "_tmp":
return True
return cls._create_submodel(execute)
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
if major == "0" and int(minor) < 2:
cls._db_create(execute)
elif major == "0" and int(minor) == 2:
if int(release) < 8:
cls._db_create(execute)
return cls._update_submodel(execute, version, data)
@classmethod
def _db_load(cls, execute, data=None):
new = []
scenario = data["scenario"]
loaded = data['loaded_pid']
table = execute(
"SELECT pamhyr_id, deleted, name, script " +
"FROM ensemble_distribution " +
f"WHERE pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
)
for row in table:
it = iter(row)
id = next(it)
deleted = (next(it) == 1)
name = next(it)
script = next(it)
new_distribution = cls(
id, name=name, script=script,
status=data["status"]
)
if deleted:
new_distribution.set_as_deleted()
loaded.add(id)
new.append(new_distribution)
return new
def _db_save(self, execute, data=None):
# Only save custom distribution
if self._type != "custom":
return True
if not self.must_be_saved():
return True
execute(
"INSERT INTO " +
"ensemble_distribution(pamhyr_id, deleted, " +
" name, script) " +
"VALUES (?, ?, ?, ?)",
self.pamhyr_id, self.is_deleted(),
self._name, self._script
)
return True
def _data_traversal(self,
predicate=lambda obj, data: True,
modifier=lambda obj, data: None,
data={}):
if predicate(self, data):
modifier(self, data)
def random(self, r):
raise NotImplementedMethodeError(cls, cls._load)
###########################
# DISTRIBUTION IMPLEMENTATION #
###########################
class Uniform(Distribution):
_sub_classes = []
def __init__(self, id: int = -1,
name: str = "uniform", script: str = "",
status=None):
super(Uniform, self).__init__(
id=id, status=status,
name=name, script=script
)
self._labels = ["low", "high"]
self._default_values = [20.0, 40.0]
def random(self, params, nb):
lst = params.copy()
lst.append(nb)
return np.random.uniform(*lst)
class Normal(Distribution):
_sub_classes = []
def __init__(self, id: int = -1,
name: str = "normal", script: str = "",
status=None):
super(Normal, self).__init__(
id=id, status=status,
name=name, script=script
)
self._labels = ["loc", "scale"]
self._default_values = [30.0, 5.0]
def random(self, params, nb):
lst = params.copy()
lst.append(nb)
return np.random.normal(*lst)
class Poisson(Distribution):
_sub_classes = []
def __init__(self, id: int = -1,
name: str = "poisson", script: str = "",
status=None):
super(Poisson, self).__init__(
id=id, status=status,
name=name, script=script
)
self._labels = ["lam"]
self._default_values = [5.0]
def random(self, params, nb):
lst = params.copy()
lst.append(nb)
return np.random.poisson(*lst)
class Custom(Distribution):
_sub_classes = []
def __init__(self, id: int = -1,
name: str = "", script: str = "",
status=None):
super(Custom, self).__init__(
id=id, status=status,
name=name, script=script
)
self._labels = ["custom"]
self._type = "custom"
self._default_values = ""
def random(self, params, nb):
try:
# Run script to (re)define the sample distribution
f = eval(self._script)
return f(params, nb)
except Exception as e:
logger_exception(e)
return None # TODO: Raise helpful exception
+60
View File
@@ -0,0 +1,60 @@
# DistributionList.py -- Pamhyr
# Copyright (C) 2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
from tools import trace, timer
from Model.Tools.PamhyrListExt import PamhyrModelList
from Model.Ensembles.Distribution import *
class DistributionList(PamhyrModelList):
_sub_classes = [Distribution]
@classmethod
def _db_load(cls, execute, data=None):
new = cls(status=data['status'])
# Default distributions
new._lst = [
Uniform(status=data['status']),
Normal(status=data['status']),
Poisson(status=data['status']),
]
# DB custom distributions
new._lst += Distribution._db_load(
execute, data
)
return new
def _db_save(self, execute, data={}):
execute(
"DELETE FROM ensemble_distribution"
)
for fun in self._lst:
fun._db_save(execute, data)
return True
def new(self, index):
r = Custom(status=self._status)
self._lst.insert(index, r)
self._status.modified()
return r
+254
View File
@@ -0,0 +1,254 @@
# Ensemble.py -- Pamhyr
# Copyright (C) 2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
import struct
import logging
import itertools
import numpy as np
from Model.Tools.PamhyrDB import SQLSubModel
from Model.Scenario import Scenario
from Model.Ensembles.Distribution import Uniform
logger = logging.getLogger()
class Ensemble(SQLSubModel):
_sub_classes = []
def __init__(self, id: int = -1, name: str = "",
distribution=None, params=[0., 100.],
data_type=None, target_data=None,
status=None, owner_scenario=-1):
super(Ensemble, self).__init__(
id=id, status=status,
owner_scenario=owner_scenario
)
self._name = name
self._data_type = data_type
self._distribution = distribution
self._params = params
self._target_data = target_data
@classmethod
def _db_create(cls, execute, ext=""):
execute(f"""
CREATE TABLE ensemble{ext} (
{cls.create_db_add_pamhyr_id()},
deleted BOOLEAN NOT NULL DEFAULT FALSE,
name TEXT NOT NULL,
type VARCHAR(8) NOT NULL,
distribution INTEGER NOT NULL,
distribution_name VARCHAR(32) NOT NULL,
params BLOB NOT NULL,
params_len INTEGER NOT NULL,
data_pid INTEGER NOT NULL,
{Scenario.create_db_add_scenario()},
{Scenario.create_db_add_scenario_fk()},
PRIMARY KEY(pamhyr_id, scenario)
)
""")
if ext == "_tmp":
return True
return cls._create_submodel(execute)
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
if major == "0" and int(minor) < 2:
cls._db_create(execute)
elif major == "0" and int(minor) == 2:
if int(release) < 8:
cls._db_create(execute)
return cls._update_submodel(execute, version, data)
@classmethod
def _db_load(cls, execute, data=None):
new = []
scenario = data["scenario"]
distributions = data["ens_distributions"]
stricklers = data["stricklers"]
loaded = data['loaded_pid']
table = execute(
"SELECT pamhyr_id, deleted, name, type, " +
"distribution, distribution_name, params, params_len, data_pid, " +
"scenario " +
"FROM ensemble " +
f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
)
for row in table:
it = iter(row)
id = next(it)
deleted = (next(it) == 1)
name = next(it)
data_type = next(it)
fid = next(it)
fname = next(it)
params = next(it)
params_len = next(it)
data_pid = next(it)
owner_scenario = next(it)
def fn(f): return f._name == fname
if fid != -1:
def fn(f): return f._pamhyr_id == fid
distribution = next(
filter(fn, distributions.lst),
None
)
target_data = next(
filter(
lambda s: s._pamhyr_id == data_pid,
stricklers.lst
),
None
)
rdata = list(cls._decode_params(params, params_len))
new_ensemble = cls(
id, name=name,
distribution=distribution,
params=rdata,
data_type=data_type,
target_data=target_data,
status=data["status"],
owner_scenario=owner_scenario
)
if deleted:
new_ensemble.set_as_deleted()
loaded.add(id)
new.append(new_ensemble)
return new
def _db_save(self, execute, data=None):
if not self.must_be_saved():
return True
execute(
"DELETE FROM ensemble " +
f"WHERE pamhyr_id = {self.pamhyr_id} " +
f"AND scenario = {self._status.scenario_id}"
)
bparams, length = self._encode_params()
if self._distribution is None:
fid = -1
fname = "NULL"
else:
fid = self._distribution._pamhyr_id
fname = self._distribution._name
if self._distribution._type == "generic":
fid = -1
data_pid = -1
if self._target_data is not None:
data_pid = self._target_data._pamhyr_id
execute(
"INSERT INTO " +
"ensemble(pamhyr_id, deleted, name, type, " +
" distribution, distribution_name, params, params_len, " +
" data_pid, scenario) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
self.pamhyr_id, self.is_deleted(),
self._name, self._data_type,
fid, fname, bparams, length,
data_pid, self._status.scenario_id
)
return True
def _encode_params(self):
length = len(self._params)
data_format = ">" + ''.join(itertools.repeat("d", length))
return struct.pack(data_format, *self._params), length
@classmethod
def _decode_params(cls, bparams, length):
data_format = ">" + ''.join(itertools.repeat("d", length))
return struct.unpack(data_format, bparams)
def random(self, nb):
return np.nditer(
self._distribution.random(
self._params, nb
)
)
@property
def name(self):
return self._name
@name.setter
def name(self, name):
self._name = name
self._status.modified()
@property
def distribution(self):
return self._distribution
@distribution.setter
def distribution(self, distribution):
self._distribution = distribution
self._status.modified()
@property
def params(self):
return self._params
@params.setter
def params(self, params):
self._params = params
self._status.modified()
@property
def data_type(self):
return self._data_type
@data_type.setter
def data_type(self, data_type):
self._data_type = data_type
self._status.modified()
@property
def target_data(self):
return self._target_data
@target_data.setter
def target_data(self, target_data):
self._target_data = target_data
self._status.modified()
+53
View File
@@ -0,0 +1,53 @@
# EnsembleList.py -- Pamhyr
# Copyright (C) 2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
from tools import trace, timer
from Model.Tools.PamhyrListExt import PamhyrModelList
from Model.Ensembles.Ensemble import Ensemble
class EnsembleList(PamhyrModelList):
_sub_classes = [Ensemble]
@classmethod
def _db_load(cls, execute, data=None):
new = cls(status=data['status'])
new._lst = Ensemble._db_load(
execute, data
)
return new
def _db_save(self, execute, data=None):
execute(
"DELETE FROM ensemble " +
f"WHERE scenario = {self._status.scenario_id}"
)
for ens in self._lst:
ens._db_save(execute, data=data)
return True
def new(self, index):
r = Ensemble(status=self._status)
self._lst.insert(index, r)
self._status.modified()
return r
+1 -1
View File
@@ -1,5 +1,5 @@
# Except.py -- Pamhyr model exceptions
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+11 -4
View File
@@ -1,5 +1,5 @@
# Friction.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -228,9 +228,10 @@ class Friction(SQLSubModel):
ssi = self._status.scenario_id
return (
self._begin_strickler._owner_scenario == ssi
# or self._end_strickler._owner_scenario == ssi
or super(Friction, self).must_be_saved()
self._begin_strickler is not None
and (self._begin_strickler._owner_scenario == ssi
# or self._end_strickler._owner_scenario == ssi
or super(Friction, self).must_be_saved())
)
def _db_save(self, execute, data=None):
@@ -364,3 +365,9 @@ class Friction(SQLSubModel):
# self.end_strickler.medium])
return minor, medium
def update_rks(self, begin_rk, end_rk):
self._begin_rk = begin_rk
self._end_rk = end_rk
self.modified()
+1 -1
View File
@@ -1,5 +1,5 @@
# FrictionList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+368
View File
@@ -0,0 +1,368 @@
# GeoTIFF.py -- Pamhyr
# Copyright (C) 2024-2025 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
import os
import struct
import logging
from functools import reduce
from tools import trace, timer
from Model.Tools.PamhyrDB import SQLSubModel
from Model.Except import NotImplementedMethodeError
from Model.Scenario import Scenario
try:
import rasterio
import rasterio.control
import rasterio.crs
import rasterio.sample
import rasterio.vrt
import rasterio._features
from rasterio.io import MemoryFile
_rasterio_loaded = True
except Exception as e:
print(f"Module 'rasterio' is not available: {e}")
_rasterio_loaded = False
logger = logging.getLogger()
class GeoTIFF(SQLSubModel):
_sub_classes = []
def __init__(self, id: int = -1, enabled=True,
name="", description="",
path="", coordinates=None,
status=None, owner_scenario=-1):
super(GeoTIFF, self).__init__(
id=id, status=status,
owner_scenario=owner_scenario
)
self._enabled = enabled
self._name = f"GeoTIFF #{self._pamhyr_id}" if name == "" else name
self._description = description
self._file_bytes = b''
if coordinates is None:
self._coordinates = {
"bottom": 0.0,
"top": 0.0,
"left": 0.0,
"right": 0.0,
}
else:
self._coordinates = coordinates
self._file_name = ""
if path != "":
self.read_file(path)
self._memfile = None
def __getitem__(self, key):
value = None
if key == "enabled":
value = self._enabled
elif key == "name":
value = self.name
elif key == "description":
value = self.description
elif key == "file_name":
value = self.file_name
elif key == "coordinates":
value = self.coordinates
elif key == "coordinates_bottom":
value = self.coordinates["bottom"]
elif key == "coordinates_top":
value = self.coordinates["top"]
elif key == "coordinates_left":
value = self.coordinates["left"]
elif key == "coordinates_right":
value = self.coordinates["right"]
elif key == "memfile":
value = self.memfile
return value
def __setitem__(self, key, value):
if key == "enabled":
self.enabled = value
elif key == "name":
self.name = value
elif key == "description":
self.description = value
elif key == "file_name":
if self._file_name != value:
self.read_file(value)
elif key == "coordinates":
self.coordinates = value
elif key == "coordinates_bottom" or key == "bottom":
self.coordinates["bottom"] = value
elif key == "coordinates_top" or key == "top":
self.coordinates["top"] = value
elif key == "coordinates_left" or key == "left":
self.coordinates["left"] = value
elif key == "coordinates_right" or key == "right":
self.coordinates["right"] = value
self.modified()
@property
def enabled(self):
return self._enabled
@enabled.setter
def enabled(self, enabled):
self._enabled = enabled
self.modified()
def is_enabled(self):
return self._enabled
@property
def name(self):
return self._name
@name.setter
def name(self, name):
self._name = name
self.modified()
@property
def description(self):
return self._description
@description.setter
def description(self, description):
self._description = description
self.modified()
@property
def file_name(self):
return self._file_name
@file_name.setter
def file_name(self, file_name):
self._file_name = file_name
self.modified()
@property
def coordinates(self):
return self._coordinates
@coordinates.setter
def coordinates(self, coordinates):
self._coordinates = coordinates
self.modified()
@property
def coord_bottom(self):
if self._coordinates is None:
return 0.0
return self._coordinates["bottom"]
@property
def coord_top(self):
if self._coordinates is None:
return 0.0
return self._coordinates["top"]
@property
def coord_left(self):
if self._coordinates is None:
return 0.0
return self._coordinates["left"]
@property
def coord_right(self):
if self._coordinates is None:
return 0.0
return self._coordinates["right"]
@property
def memfile(self):
if not _rasterio_loaded:
return None
if self._file_bytes == b'':
return None
if self._memfile is None:
self._memfile = MemoryFile()
self._memfile.write(self._file_bytes)
return self._memfile
def read_file(self, path):
logger.debug(f"Read GeoTIFF file at : '{path}'")
self._file_name = path
self._file_bytes = b''
self._memfile = None
nbytes = 0
with open(path, "rb") as f:
while True:
data = f.read(4096)
if not data:
break
nbytes += len(data)
self._file_bytes += data
logger.debug(f"Read GeoTIFF: {nbytes} bytes readed")
def write_file(self, path):
with open(path, "w+b") as f:
f.write(self._file_bytes)
@classmethod
def _db_create(cls, execute, ext=""):
execute(f"""
CREATE TABLE geotiff{ext} (
{cls.create_db_add_pamhyr_id()},
enabled BOOLEAN NOT NULL,
deleted BOOLEAN NOT NULL DEFAULT FALSE,
name TEXT NOT NULL,
description TEXT NOT NULL,
file_name TEXT NOT NULL,
file_bytes BLOB NOT NULL,
coordinates_bottom REAL NOT NULL,
coordinates_top REAL NOT NULL,
coordinates_left REAL NOT NULL,
coordinates_right REAL NOT NULL,
{Scenario.create_db_add_scenario()},
{Scenario.create_db_add_scenario_fk()},
PRIMARY KEY(pamhyr_id, scenario)
)
""")
return cls._create_submodel(execute)
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
if major == "0" and int(minor) < 2:
cls._db_create(execute)
if major == "0" and int(minor) == 2:
if int(release) < 3:
cls._db_create(execute)
return True
@classmethod
def _db_load(cls, execute, data=None):
new = []
scenario = data["scenario"]
loaded = data['loaded_pid']
if scenario is None:
return new
table = execute(
"SELECT pamhyr_id, enabled, deleted, " +
"name, description, file_name, file_bytes, " +
"coordinates_bottom, coordinates_top, " +
"coordinates_left, coordinates_right, " +
"scenario " +
"FROM geotiff " +
f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
)
if table is not None:
for row in table:
it = iter(row)
id = next(it)
enabled = (next(it) == 1)
deleted = (next(it) == 1)
name = next(it)
description = next(it)
file_name = next(it)
file_bytes = next(it)
coordinates_bottom = next(it)
coordinates_top = next(it)
coordinates_left = next(it)
coordinates_right = next(it)
owner_scenario = next(it)
f = cls(
id=id, enabled=enabled, name=name,
description=description, coordinates={
"bottom": coordinates_bottom,
"top": coordinates_top,
"left": coordinates_left,
"right": coordinates_right,
},
status=data['status'],
owner_scenario=owner_scenario
)
if deleted:
f.set_as_deleted()
f._file_bytes = file_bytes
loaded.add(id)
new.append(f)
data["scenario"] = scenario.parent
new += cls._db_load(execute, data)
data["scenario"] = scenario
return new
def _db_save(self, execute, data=None):
if not self.must_be_saved():
return True
execute(
"INSERT INTO geotiff (" +
"pamhyr_id, enabled, deleted, " +
"name, description, file_name, file_bytes, " +
"coordinates_bottom, coordinates_top, " +
"coordinates_left, coordinates_right, " +
"scenario) " +
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?)",
self._pamhyr_id,
self._enabled,
self.is_deleted(),
self.name,
self.description,
self.file_name,
self._file_bytes,
self.coordinates['bottom'],
self.coordinates['top'],
self.coordinates['left'],
self.coordinates['right'],
self._status.scenario_id,
)
return True
+59
View File
@@ -0,0 +1,59 @@
# GeoTIFFList.py -- Pamhyr
# Copyright (C) 2024-2025 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
from tools import trace, timer
from Model.Except import NotImplementedMethodeError
from Model.Tools.PamhyrListExt import PamhyrModelList
from Model.GeoTIFF.GeoTIFF import GeoTIFF
class GeoTIFFList(PamhyrModelList):
_sub_classes = [GeoTIFF]
@classmethod
def _db_load(cls, execute, data=None):
new = cls(status=data["status"])
new._lst = GeoTIFF._db_load(execute, data)
return new
def _db_save(self, execute, data=None):
ok = True
# Delete previous data
execute(
"DELETE FROM geotiff " +
f"WHERE scenario = {self._status.scenario_id}"
)
for gt in self._lst:
ok &= gt._db_save(execute, data)
return ok
@property
def files(self):
return self.lst
def new(self, index):
n = GeoTIFF(status=self._status)
self.insert(index, n)
self._status.modified()
return n
+1 -1
View File
@@ -1,5 +1,5 @@
# Point.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# PointXY.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+19 -1
View File
@@ -1,5 +1,5 @@
# PointXYZ.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -66,6 +66,11 @@ class PointXYZ(Point):
)
""")
execute(
"CREATE INDEX idx_point " +
"ON geometry_pointXYZ(profile, scenario);"
)
return cls._create_submodel(execute)
@classmethod
@@ -90,6 +95,12 @@ class PointXYZ(Point):
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
)
# Try to create index at each update
execute(
"CREATE INDEX IF NOT EXISTS idx_point " +
"ON geometry_pointXYZ(profile, scenario);"
)
return cls._update_submodel(execute, version, data)
@classmethod
@@ -338,6 +349,13 @@ class PointXYZ(Point):
self._z = float(value)
self.modified()
def shift(self, x, y, z):
self.x += x
self.y += y
self.z += z
self.modified()
def get_coordinate(self):
return (self._x, self._y, self._z)
+25 -5
View File
@@ -1,5 +1,5 @@
# Profile.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -76,12 +76,32 @@ class Profile(object):
return self.points[index]
def named_point(self, name):
return next((p for p in self.points if p.name == name), None)
if name == "un":
return self.points[0]
elif name == "np":
return self.points[-1]
elif name == "talweg":
zm = self.z_min()
return next((p for p in self.points if p.z == zm), None)
else:
return next((p for p in self.points if p.name == name), None)
def named_point_index(self, name):
return next(
(p for p in enumerate(self.points) if p[1].name == name), None
)[0]
if name == "un":
return 0
elif name == "np":
return len(self.points) - 1
elif name == "talweg":
zm = self.z_min()
return next(
(p for p in enumerate(self.points) if p[1].z == zm),
None
)[0]
else:
return next(
(p for p in enumerate(self.points) if p[1].name == name),
None
)[0]
@property
def reach(self):
+70 -44
View File
@@ -1,5 +1,5 @@
# ProfileXYZ.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@ from typing import List
from functools import reduce
from dataclasses import dataclass
from tools import timer, flatten
from tools import trace, timer, flatten
from shapely import geometry
from Model.Tools.PamhyrDB import SQLSubModel
@@ -91,6 +91,9 @@ class ProfileXYZ(Profile, SQLSubModel):
self._station = []
self.station_up_to_date = False
self._get_water_limits_cache = {}
self._get_water_limits_ac_cache = {}
@classmethod
def _db_create(cls, execute, ext=""):
execute(f"""
@@ -396,7 +399,6 @@ class ProfileXYZ(Profile, SQLSubModel):
for point in self._points:
p = point.copy()
print(p)
new_p._points.append(p)
new_p.modified()
@@ -620,6 +622,7 @@ class ProfileXYZ(Profile, SQLSubModel):
"""
return [x for x in lst if not np.isnan(x)]
@timer
def speed(self, q, z):
area = self.wet_area(z)
@@ -671,6 +674,7 @@ class ProfileXYZ(Profile, SQLSubModel):
length += line.length
return length
@timer
def compute_wet_area(self, z):
area = 0.0
if len(self.tab.L) > 0:
@@ -711,6 +715,7 @@ class ProfileXYZ(Profile, SQLSubModel):
if len(line.coords) > 2:
poly = geometry.Polygon(line)
area += poly.area
return area
def wet_radius(self, z):
@@ -733,6 +738,7 @@ class ProfileXYZ(Profile, SQLSubModel):
line = geometry.LineString(list(zip(station, zz)))
return line
@timer
def wet_lines(self, z):
points = self._points
if len(points) < 3:
@@ -809,7 +815,6 @@ class ProfileXYZ(Profile, SQLSubModel):
return points
def get_nb_wet_areas(self, z):
n_zones = 0
points = self._points
if points[0].z <= z:
@@ -821,10 +826,13 @@ class ProfileXYZ(Profile, SQLSubModel):
return n_zones
@timer
def get_all_water_limits_ac(self, z):
"""
Determine all water limits for z elevation.
"""
if z in self._get_water_limits_ac_cache:
return self._get_water_limits_ac_cache[z]
points = self._points
if len(points) < 3:
@@ -857,69 +865,94 @@ class ProfileXYZ(Profile, SQLSubModel):
logger.error(f"ERROR in get_all_water_limits_ac")
return [], []
return start, list(reversed(end))
res = start, list(reversed(end))
self._get_water_limits_ac_cache[z] = res
return res
@timer
def get_water_limits(self, z):
if z in self._get_water_limits_cache:
return self._get_water_limits_cache[z]
v = self.get_water_limits_compute(z)
return v
def get_water_limits_compute(self, z):
"""
Determine left and right limits of water elevation.
"""
# Get the index of first point with elevation lesser than water
# elevation (for the right and left river side)
i_left = -1
i_right = -1
i_left = next(
filter(
lambda i: self.point(i).z <= z,
range(self.number_points)
),
-1
)
for i in range(self.number_points):
if self.point(i).z <= z:
i_left = i
break
for i in reversed(range(self.number_points)):
if self.point(i).z <= z:
i_right = i
break
i_right = next(
filter(
lambda i: self.point(i).z <= z,
reversed(range(self.number_points))
),
-1
)
# Interpolate points at river left side
if (i_left > 0):
if abs(self.point(i_left - 1).z - self.point(i_left).z) < 1e-20:
pt_left = self.point(i_left)
pi = self.point(i_left)
pim1 = self.point(i_left - 1)
if abs(pim1.z - pi.z) < 1e-20:
pt_left = pi
else:
fact = (z - self.point(i_left).z) / \
(self.point(i_left - 1).z - self.point(i_left).z)
x = self.point(i_left).x + fact * \
(self.point(i_left - 1).x - self.point(i_left).x)
y = self.point(i_left).y + fact * \
(self.point(i_left - 1).y - self.point(i_left).y)
fact = (z - pi.z) / (pim1.z - pi.z)
x = pi.x + fact * (pim1.x - pi.x)
y = pi.y + fact * (pim1.y - pi.y)
pt_left = PointXYZ(x=x, y=y, z=z, name="wl_left")
else:
pt_left = self.point(0)
# Interpolate points at river right side
if (i_right < self.number_points - 1):
if abs(self.point(i_right + 1).z - self.point(i_right).z) < 1e-20:
pt_right = self.point(i_right)
pi = self.point(i_right)
pip1 = self.point(i_right + 1)
if abs(pip1.z - pi.z) < 1e-20:
pt_right = pi
else:
fact = (z - self.point(i_right).z) / \
(self.point(i_right + 1).z - self.point(i_right).z)
x = self.point(i_right).x + fact * \
(self.point(i_right + 1).x - self.point(i_right).x)
y = self.point(i_right).y + fact * \
(self.point(i_right + 1).y - self.point(i_right).y)
fact = (z - pi.z) / (pip1.z - pi.z)
x = pi.x + fact * (pip1.x - pi.x)
y = pi.y + fact * (pip1.y - pi.y)
pt_right = PointXYZ(x=x, y=y, z=z, name="wl_right")
else:
pt_right = self.point(self.number_points - 1)
return pt_left, pt_right
v = (pt_left, pt_right)
# Put results in cache
self._get_water_limits_cache[z] = v
# Create a generator to improve results data reading speed
yield v
@timer
def compute_tabulation(self):
sorted_points = sorted(self._points, key=lambda p: p.z)
self.tab.z = np.array([p.z for p in sorted_points], np.float64)
self.tab.L = np.zeros(len(self.tab.z), np.float64)
self.tab.A = np.zeros(len(self.tab.z), np.float64)
for i in range(1, len(self.tab.z)):
self.tab.L[i] = self.compute_wet_width(self.tab.z[i])
dx = (self.tab.L[i] + self.tab.L[i-1])/2
dz = self.tab.z[i] - self.tab.z[i-1]
self.tab.A[i] = self.tab.A[i-1] + dz * dx
self.tab_up_to_date = True
@@ -1074,16 +1107,10 @@ class ProfileXYZ(Profile, SQLSubModel):
def shift(self, x, y, z):
for p in self._points:
p.x = p.x + x
p.y = p.y + y
p.z = p.z + z
p.shift(x, y, z)
self.modified()
def modified(self):
self.tab_up_to_date = False
self.station_up_to_date = False
def add_npoints(self, npoints):
# add npoints in a profile
for k in range(npoints):
@@ -1101,12 +1128,11 @@ class ProfileXYZ(Profile, SQLSubModel):
self.point(i+1).z = 0.5 * self.point(i).z + 0.5 * self.point(i+2).z
def copy(self):
p = ProfileXYZ(id=self.id,
name=self.name,
p = ProfileXYZ(name=self.name,
rk=self.rk,
reach=self.reach,
num=self.num,
status=self._status)
for i, k in enumerate(self.points):
p.insert_point(i, k.copy())
+50 -6
View File
@@ -1,5 +1,5 @@
# Reach.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -52,6 +52,11 @@ class Reach(SQLSubModel):
self._guidelines_is_valid = False
self._guidelines = {}
super(Reach, self).__init__(
id=parent.pamhyr_id,
status=status,
)
@property
def pamhyr_id(self):
return self._parent.pamhyr_id
@@ -60,6 +65,10 @@ class Reach(SQLSubModel):
def _pamhyr_id(self):
return self._parent.pamhyr_id
@_pamhyr_id.setter
def _pamhyr_id(self, id):
return
@classmethod
def _db_create(cls, execute):
return cls._create_submodel(execute)
@@ -103,6 +112,9 @@ class Reach(SQLSubModel):
predicate=lambda obj, data: True,
modifier=lambda obj, data: None,
data={}):
if predicate(self, data):
modifier(self, data)
for p in self._profiles:
p._data_traversal(predicate, modifier, data)
@@ -195,13 +207,16 @@ class Reach(SQLSubModel):
"""
if profile in self._profiles:
self.undelete([profile])
profile.num = index
else:
self._profiles.insert(index, profile)
gi = self.get_global_profil_index(index)
profile.num = gi
self._profiles.insert(gi, profile)
self.modified()
def delete(self, indexes):
"""Delete some elements in profile list
"""Set some elements as deleted in profile list
Args:
indexes: The list of index to delete
@@ -209,11 +224,12 @@ class Reach(SQLSubModel):
Returns:
Nothing.
"""
gi = [self.get_global_profil_index(i) for i in indexes]
list(
map(
lambda p: p[1].set_as_deleted(),
filter(
lambda e: e[0] in indexes,
lambda e: e[0] in gi,
enumerate(self._profiles)
)
)
@@ -229,11 +245,12 @@ class Reach(SQLSubModel):
Returns:
Nothing.
"""
gi = [self.get_global_profil_index(i) for i in indexes]
self._profiles = list(
map(
lambda p: p[1],
filter(
lambda e: e[0] not in indexes,
lambda e: e[0] not in gi,
enumerate(self._profiles)
)
)
@@ -241,7 +258,7 @@ class Reach(SQLSubModel):
self.modified()
def delete_profiles(self, profiles):
"""Delete some elements in profile list
"""Set profiles list as deleted
Args:
profiles: The list of profile to delete
@@ -929,3 +946,30 @@ class Reach(SQLSubModel):
nr2._profiles = list(map(lambda p: p.cloned_for(nr2), nr2_profiles))
return nr1, nr2
def get_local_profil_index(self, index):
local_index = -1
for i, p in enumerate(self._profiles):
if not p.is_deleted():
local_index += 1
if i == index:
break
return local_index
def get_global_profil_index(self, index):
local_index = -1
for i, p in enumerate(self._profiles):
if not p.is_deleted():
local_index += 1
if local_index == index:
global_index = i
break
return global_index
def update_rks(self, rks):
for rk, profile in zip(rks, self.profiles):
profile.rk = rk
self.modified()
+1 -1
View File
@@ -1,5 +1,5 @@
# Vector_1d.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1,5 +1,5 @@
# HydraulicStructures.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -183,7 +183,6 @@ class BasicHS(SQLSubModel):
bhs._data = BHSValue._db_load(
execute, data
)
print(f"{bhs_pid} : {deleted}")
if deleted:
bhs.set_as_deleted()
+1 -1
View File
@@ -1,5 +1,5 @@
# Types.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# Value.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1,5 +1,5 @@
# HydraulicStructures.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -274,6 +274,9 @@ class HydraulicStructure(SQLSubModel):
return hs
def _db_save(self, execute, data=None):
if not self.must_be_saved():
return True
execute(
"DELETE FROM hydraulic_structures " +
f"WHERE pamhyr_id = {self.pamhyr_id} " +
@@ -1,5 +1,5 @@
# HydraulicStructuresList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1,5 +1,5 @@
# InitialConditions.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -225,6 +225,8 @@ class Data(SQLSubModel):
return new
def _db_save(self, execute, data=None):
if not self.must_be_saved():
return True
ind = data["ind"]
execute(
@@ -396,7 +398,7 @@ class InitialConditions(SQLSubModel):
@reach.setter
def reach(self, new):
self._reach = reach
self._reach = new
self.modified()
@property
@@ -537,7 +539,10 @@ class InitialConditions(SQLSubModel):
strickler = 25.0
if not compute_discharge:
discharge = data_discharge[profile.rk]
if profile.rk in data_discharge:
discharge = data_discharge[profile.rk]
else:
discharge = 0.0
else:
discharge = (
# ((width * 0.8)
@@ -583,8 +588,6 @@ class InitialConditions(SQLSubModel):
for data in self._data:
data_height[data["rk"].rk] = data["height"]
print(data_height)
incline = self._reach.reach.get_incline_median_mean()
logger.debug(f"incline = {incline}")
@@ -605,7 +608,10 @@ class InitialConditions(SQLSubModel):
strickler = 25.0
if not compute_height:
height = data_height[profile.rk]
if profile.rk in data_height:
height = data_height[profile.rk]
else:
height = 0.0
else:
if abs(incline) <= 0:
height = 0.0
@@ -656,7 +662,10 @@ class InitialConditions(SQLSubModel):
for profile in profiles:
if not compute_discharge:
d = data_discharge[profile.rk]
if profile.rk in data_discharge:
d = data_discharge[profile.rk]
else:
d = 0.0
else:
d = discharge
elevation = interp(profile.rk,
@@ -1,5 +1,5 @@
# InitialConditionsDict.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1,5 +1,5 @@
# InitialConditionsAdisTS.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -79,16 +79,12 @@ class InitialConditionsAdisTS(SQLSubModel):
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
created = False
if major == "0" and int(minor) <= 1:
if int(release) < 6:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
if cls.is_table_exists(execute, "initial_conditions_adists"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
return True
@@ -267,7 +263,7 @@ class InitialConditionsAdisTS(SQLSubModel):
@name.setter
def name(self, name):
self._name = name
self._status.modified()
self.modified()
@property
def pollutant(self):
@@ -276,7 +272,7 @@ class InitialConditionsAdisTS(SQLSubModel):
@pollutant.setter
def pollutant(self, pollutant):
self._pollutant = pollutant
self._status.modified()
self.modified()
@property
def concentration(self):
@@ -285,7 +281,7 @@ class InitialConditionsAdisTS(SQLSubModel):
@concentration.setter
def concentration(self, concentration):
self._concentration = concentration
self._status.modified()
self.modified()
@property
def eg(self):
@@ -294,7 +290,7 @@ class InitialConditionsAdisTS(SQLSubModel):
@eg.setter
def eg(self, eg):
self._eg = eg
self._status.modified()
self.modified()
@property
def em(self):
@@ -303,7 +299,7 @@ class InitialConditionsAdisTS(SQLSubModel):
@em.setter
def em(self, em):
self._em = em
self._status.modified()
self.modified()
@property
def ed(self):
@@ -312,7 +308,7 @@ class InitialConditionsAdisTS(SQLSubModel):
@ed.setter
def ed(self, ed):
self._ed = ed
self._status.modified()
self.modified()
@property
def enabled(self):
@@ -321,28 +317,45 @@ class InitialConditionsAdisTS(SQLSubModel):
@enabled.setter
def enabled(self, enabled):
self._enabled = enabled
self._status.modified()
self.modified()
def new(self, index):
n = ICAdisTSSpec(status=self._status)
self._data.insert(index, n)
self._status.modified()
self.modified()
return n
def delete(self, data):
self._data = list(
filter(
lambda x: x not in data,
self._data
list(
map(
lambda x: x.set_as_deleted(),
data
)
)
self._status.modified()
self.modified()
def delete_i(self, indexes):
for ind in indexes:
del self._data[ind]
self._status.modified()
list(
map(
lambda e: e[1].set_as_deleted(),
filter(
lambda e: e[0] in indexes,
enumerate(self._data)
)
)
)
self.modified()
def insert(self, index, data):
self._data.insert(index, data)
self._status.modified()
if data in self._data:
self.undelete([data])
else:
self._data.insert(index, data)
self.modified()
def undelete(self, lst):
for x in lst:
x.set_as_not_deleted()
self.modified()
@@ -1,5 +1,5 @@
# InitialConditionsAdisTSList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1,5 +1,5 @@
# InitialConditionsAdisTSSpec.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ class ICAdisTSSpec(SQLSubModel):
_sub_classes = []
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=None):
super(ICAdisTSSpec, self).__init__()
self._status = status
@@ -77,16 +77,12 @@ class ICAdisTSSpec(SQLSubModel):
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
created = False
if major == 0 and minor < 1:
if int(release) < 6:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
if cls.is_table_exists(execute, "initial_conditions_adists_spec"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
return True
@@ -194,7 +190,7 @@ class ICAdisTSSpec(SQLSubModel):
new_spec.rate = rate
new_spec.enabled = enabled
loaded.add(pid)
# loaded.add(pid)
new.append(new_spec)
data["scenario"] = scenario.parent
@@ -211,7 +207,7 @@ class ICAdisTSSpec(SQLSubModel):
sql = (
"INSERT INTO " +
"initial_conditions_adists_spec(id, deleted, " +
"initial_conditions_adists_spec(pamhyr_id, deleted, " +
"ic_default, name, reach, " +
"start_rk, end_rk, concentration, eg, em, ed, rate, " +
"enabled, scenario) " +
@@ -1,5 +1,5 @@
# LateralContribution.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -147,9 +147,9 @@ class Data(SQLSubModel):
it = iter(v)
pid = next(it)
delete = next(it)
data0 = bc._types[0](next(it))
data1 = bc._types[1](next(it))
deleted = next(it)
data0 = lc._types[0](next(it))
data1 = lc._types[1](next(it))
owner_scenario = next(it)
nd = cls(
@@ -1,5 +1,5 @@
# LateralContributionList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1,5 +1,5 @@
# LateralContributionTypes.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1,5 +1,5 @@
# LateralContributionAdisTS.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -69,14 +69,12 @@ class Data(SQLSubModel):
major, minor, release = version.strip().split(".")
created = False
if major == "0" and int(minor) <= 1:
if int(release) < 7:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
if cls.is_table_exists(
execute, "lateral_contribution_data_adists"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
return True
@@ -132,11 +130,13 @@ class Data(SQLSubModel):
if scenario is None:
return new
lca = data["lca"]
table = execute(
"SELECT pamhyr_id, deleted, data0, data1 " +
"SELECT pamhyr_id, deleted, data0, data1, scenario " +
"FROM lateral_contribution_data_adists " +
f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) " +
f"AND lca = '{lca.id}'"
)
@@ -150,16 +150,16 @@ class Data(SQLSubModel):
data1 = next(it)
owner_scenario = next(it)
data = cls(
lc = cls(
data0, data1,
id=pid, status=status,
owner_scenario=owner_scenario
)
if deleted:
data.set_as_deleted()
lc.set_as_deleted()
loaded.add(pid)
new.append(data)
new.append(lc)
data["scenario"] = scenario.parent
new += cls._db_load(execute, data)
@@ -175,7 +175,7 @@ class Data(SQLSubModel):
execute(
"INSERT INTO " +
"lateral_contribution_adists(pamhyr_id, deleted," +
"lateral_contribution_data_adists(pamhyr_id, deleted," +
"data0, data1, lca, scenario) " +
"VALUES (" +
f"{self.id}, {self._db_format(self.is_deleted())}, " +
@@ -241,15 +241,13 @@ class LateralContributionAdisTS(SQLSubModel):
major, minor, release = version.strip().split(".")
created = False
if major == "0" and int(minor) <= 1:
if int(release) < 7:
if major == "0" and int(minor) < 2:
if cls.is_table_exists(execute, "lateral_contribution_adists"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
cls._db_update_to_0_2_0(execute, data)
if not created:
return cls._update_submodel(execute, version, data)
@@ -372,16 +370,18 @@ class LateralContributionAdisTS(SQLSubModel):
execute(
"INSERT INTO " +
"lateral_contribution_adists(id, deleted," +
"lateral_contribution_adists(pamhyr_id, deleted, " +
"pollutant, reach, begin_rk, end_rk, scenario) " +
"VALUES (" +
f"{self.id}, {self._db_format(self.is_deleted())}, " +
f"{self._pollutant}, {self.reach}, " +
f"{self._begin_rk}, {self._end_rk}" +
f"{self._begin_rk}, {self._end_rk}, " +
f"{self._status.scenario_id}" +
")"
)
data["lca"] = self
ind = 0
for d in self._data:
data["ind"] = ind
@@ -406,7 +406,7 @@ class LateralContributionAdisTS(SQLSubModel):
return len(
list(
filter(
lambda el: not el.is_deleted(),
lambda el: el is not None and not el.is_deleted(),
self._data
)
)
@@ -452,7 +452,12 @@ class LateralContributionAdisTS(SQLSubModel):
@property
def data(self):
return self._data.copy()
return list(
filter(
lambda el: el is not None and not el.is_deleted(),
self._data
)
)
@property
def begin_rk(self):
@@ -471,3 +476,57 @@ class LateralContributionAdisTS(SQLSubModel):
def end_rk(self, end_rk):
self._end_rk = end_rk
self.modified()
@property
def _default_0(self):
return self._types[0](0)
@property
def _default_1(self):
return self._types[1](0.0)
def add(self, index: int):
value = Data(self._default_0, self._default_1, status=self._status)
self._data.insert(index, value)
self.modified()
return value
def insert(self, index: int, data: Data):
self._data.insert(index, data)
self.modified()
def delete_i(self, indexes):
self._data = list(
map(
lambda e: e[1].set_as_deleted(),
filter(
lambda e: e[0] not in indexes,
enumerate(self.data)
)
)
)
self.modified()
def index(self, bc):
self._data.index(bc)
def get_i(self, index: int):
return self._data[index]
def get_range(self, _range):
lst = []
for r in _range:
lst.append(r)
return lst
def _set_i_c_v(self, index: int, column: int, value):
v = self._data[index]
v[column] = self._types[column](value)
self._data[index] = v
self.modified()
def set_i_0(self, index: int, value):
self._set_i_c_v(index, 0, value)
def set_i_1(self, index: int, value):
self._set_i_c_v(index, 1, value)
@@ -1,5 +1,5 @@
# LateralContributionsAdisTSList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# Edge.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# Graph.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# Node.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# Point.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# __init__.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# test_Network.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+5 -9
View File
@@ -1,5 +1,5 @@
# OutputRKAdists.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -95,16 +95,12 @@ class OutputRKAdists(SQLSubModel):
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
created = False
if major == "0" and int(minor) <= 1:
if int(release) < 7:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
if cls.is_table_exists(execute, "OutputRKAdists"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
return True
@@ -193,7 +189,7 @@ class OutputRKAdists(SQLSubModel):
"output_rk_adists(pamhyr_id, deleted, " +
"reach, rk, title, scenario) " +
"VALUES (" +
f"{self.id}, {self._db_format(self.is_deleted())}" +
f"{self.id}, {self._db_format(self.is_deleted())}, " +
f"{self._reach}, {self._rk}, " +
f"'{self._db_format(self._title)}', " +
f"{self._status.scenario_id}" +
+81 -20
View File
@@ -1,5 +1,5 @@
# Pollutants.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,6 +28,9 @@ from tools import (
from Model.Tools.PamhyrDB import SQLSubModel
from Model.Except import NotImplementedMethodeError
from Model.Scenario import Scenario
from Model.BoundaryConditionsAdisTS.BoundaryConditionAdisTS import (
BoundaryConditionAdisTS,
)
logger = logging.getLogger()
@@ -101,6 +104,12 @@ class PollutantCharacteristics(SQLSubModel):
self._ac = value
elif key == 8:
self._bc = value
self.propagate_modified()
def propagate_modified(self):
self.modified()
if hasattr(self, "_pollutant") and self._pollutant:
self._pollutant.modified()
@classmethod
def _db_create(cls, execute, ext=""):
@@ -129,16 +138,12 @@ class PollutantCharacteristics(SQLSubModel):
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
created = False
if major == "0" and int(minor) <= 1:
if int(release) < 7:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
if cls.is_table_exists(execute, "Pollutants_characteristics"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
return cls._update_submodel(execute, version, data)
@@ -253,6 +258,12 @@ class PollutantCharacteristics(SQLSubModel):
if not self.must_be_saved():
return True
execute(
"DELETE FROM pollutants_characteristics " +
f"WHERE pamhyr_id = {self.id} " +
f"AND scenario = {self._status.scenario_id}"
)
execute(
"INSERT INTO " +
"pollutants_characteristics(pamhyr_id, deleted, " +
@@ -275,7 +286,10 @@ class PollutantCharacteristics(SQLSubModel):
class Pollutants(SQLSubModel):
_sub_classes = [PollutantCharacteristics]
_sub_classes = [
PollutantCharacteristics,
# BoundaryConditionAdisTS
]
def __init__(self, id: int = -1, name: str = "",
status=None, owner_scenario=-1):
@@ -293,6 +307,11 @@ class Pollutants(SQLSubModel):
self._enabled = True
self._data = []
self._boundary_conditions_adists = []
@property
def boundary_conditions_adists(self):
return self._boundary_conditions_adists
@property
def name(self):
@@ -301,18 +320,37 @@ class Pollutants(SQLSubModel):
@name.setter
def name(self, name):
self._name = name
self._status.modified()
self.modified()
@property
def data(self):
return self._data
@data.setter
def data(self, data):
self._data = [
PollutantCharacteristics(
type=int(data[0]),
diametre=float(data[1]),
rho=float(data[2]),
porosity=float(data[3]),
cdc_riv=float(data[4]),
cdc_cas=float(data[5]),
apd=float(data[6]),
ac=float(data[7]),
bc=float(data[8]),
pollutant=self,
status=self._status
)
]
@classmethod
def _db_create(cls, execute, ext=""):
execute(f"""
CREATE TABLE pollutants{ext}(
{cls.create_db_add_pamhyr_id()},
deleted BOOLEAN NOT NULL DEFAULT FALSE,
enabled BOOLEAN NOT NULL DEFAULT TRUE,
name TEXT NOT NULL,
{Scenario.create_db_add_scenario()},
{Scenario.create_db_add_scenario_fk()}
@@ -329,14 +367,20 @@ class Pollutants(SQLSubModel):
major, minor, release = version.strip().split(".")
created = False
if major == "0" and int(minor) <= 1:
if int(release) < 7:
if major == "0" and int(minor) < 2:
if cls.is_table_exists(execute, "Pollutants"):
cls._db_update_to_0_2_0(execute, data)
else:
cls._db_create(execute)
created = True
if major == "0" and int(minor) < 2:
if not created:
cls._db_update_to_0_2_0(execute, data)
if major == "0" and minor == "2":
if int(release) < 6:
execute(f"ALTER TABLE pollutants " +
f"ADD COLUMN enabled BOOLEAN NOT NULL DEFAULT TRUE")
# cls._db_update_to_0_2_5(execute, data)
# # created = True
if not created:
return cls._update_submodel(execute, version, data)
@@ -375,7 +419,8 @@ class Pollutants(SQLSubModel):
return new
table = execute(
"SELECT pamhyr_id, deleted, name FROM pollutants " +
"SELECT pamhyr_id, deleted, enabled, name, scenario " +
"FROM pollutants " +
f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
)
@@ -386,18 +431,30 @@ class Pollutants(SQLSubModel):
pid = next(it)
deleted = (next(it) == 1)
enabled = (next(it) == 1)
name = next(it)
owner_scenario = next(it)
new_pollutant = cls(
id=pid, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
if deleted:
new_pollutant.set_as_deleted()
if not enabled:
new_pollutant.enabled = False
data["pollutant"] = new_pollutant
new_pollutant._data = PollutantCharacteristics._db_load(
execute, data.copy()
execute, data=data
)
new_pollutant._boundary_conditions_adists = (
BoundaryConditionAdisTS._db_load(
execute,
data=data
)
)
loaded.add(pid)
@@ -421,16 +478,17 @@ class Pollutants(SQLSubModel):
f"AND scenario = {self._status.scenario_id}"
)
execute(
f"DELETE FROM pollutants_characteristics " +
"DELETE FROM pollutants_characteristics " +
f"WHERE pollutant = {self.id} " +
f"AND scenario = {self._status.scenario_id}"
)
execute(
"INSERT INTO " +
"pollutants(pamhyr_id, deleted, name, scenario) " +
"pollutants(pamhyr_id, deleted, enabled, name, scenario) " +
"VALUES (" +
f"{self.id}, {self._db_format(self.is_deleted())}, " +
f"{self._db_format(self._enabled)}, " +
f"'{self._db_format(self._name)}', " +
f"{self._status.scenario_id}" +
")"
@@ -439,6 +497,9 @@ class Pollutants(SQLSubModel):
for d in self._data:
ok &= d._db_save(execute, data)
for bc in self._boundary_conditions_adists:
ok &= bc._db_save(execute, data)
return ok
def _data_traversal(self,
+1 -1
View File
@@ -19,7 +19,7 @@
from tools import trace, timer
from Model.Except import NotImplementedMethodeError
from Model.Tools.PamhyrList import PamhyrModelList
from Model.Tools.PamhyrListExt import PamhyrModelList
from Model.Pollutants.Pollutants import Pollutants
+3 -5
View File
@@ -1,5 +1,5 @@
# Reservoir.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -263,8 +263,6 @@ class Reservoir(SQLSubModel):
cls._db_update_to_0_2_0_set_node_pid(execute, table, nodes)
Scenario.update_db_add_scenario(execute, table)
print(execute(f"SELECT * FROM {table}"))
cls._db_create(execute, ext="_tmp")
execute(
f"INSERT INTO {table}_tmp " +
@@ -310,11 +308,11 @@ class Reservoir(SQLSubModel):
new_reservoir.set_as_deleted()
new_reservoir._node = None
if node_id != -1:
if node_id != -1 and node_id is not None:
new_reservoir._node = next(
filter(
lambda n: n.id == node_id, data["nodes"]
)
), None
)
data["reservoir"] = new_reservoir
+1 -1
View File
@@ -1,5 +1,5 @@
# ReservoirList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+394 -5
View File
@@ -1,5 +1,5 @@
# Results.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,6 +22,8 @@ import numpy as np
from copy import deepcopy
from datetime import datetime
from tools import timer
from Model.Scenario import Scenario
from Model.Tools.PamhyrDB import SQLSubModel
from Model.Results.River.River import River
@@ -29,11 +31,314 @@ from Model.Results.River.River import River
logger = logging.getLogger()
class AdditionalData(SQLSubModel):
_sub_classes = []
def __init__(self, id=-1, study=None, data=None):
super(AdditionalData, self).__init__(
id=id, status=study.status,
owner_scenario=study.status.scenario.id
)
self._study = study
self._data = data
@property
def data(self):
return self._data
@classmethod
def _db_create(cls, execute, ext=""):
execute(f"""
CREATE TABLE results_add_data{ext} (
{cls.create_db_add_pamhyr_id()},
result INTEGER NOT NULL,
type_x TEXT NOT NULL,
type_y TEXT NOT NULL,
legend TEXT NOT NULL,
unit TEXT NOT NULL,
data_len INTEGER NOT NULL,
x BLOB NOT NULL,
y BLOB NOT NULL,
{Scenario.create_db_add_scenario()},
{Scenario.create_db_add_scenario_fk()},
FOREIGN KEY(result) REFERENCES results(pamhyr_id),
PRIMARY KEY(pamhyr_id, result, scenario)
)
""")
if ext != "":
return True
return cls._create_submodel(execute)
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
if major == "0" and int(minor) == 2 and int(release) <= 1:
cls._db_create(execute)
return cls._update_submodel(execute, version, data)
@classmethod
def _db_load(cls, execute, data=None):
new = []
study = data['study']
status = data['status']
scenario = data["scenario"]
table = execute(
"SELECT pamhyr_id, type_x, type_y, " +
"legend, unit, data_len, x, y, " +
"scenario " +
"FROM results_add_data " +
f"WHERE scenario = {scenario.id}"
)
if table is None:
return new
for v in table:
it = iter(v)
pid = next(it)
type_x = next(it)
type_y = next(it)
legend = next(it)
unit = next(it)
data_len = next(it)
bx = next(it)
by = next(it)
owner_scenario = next(it)
data_format = ">" + ''.join(itertools.repeat("d", data_len))
x = struct.unpack(data_format, bx)
y = struct.unpack(data_format, by)
data = {
'type_x': type_x,
'type_y': type_y,
'legend': legend,
'unit': unit,
'x': x, 'y': y
}
new_data = cls(study=study)
new_data._data = data
new.append(new_data)
return new
def _db_save(self, execute, data=None):
if self._status.scenario.id != self._owner_scenario:
return
pid = self._pamhyr_id
data_len = len(self._data["x"])
data_format = ">" + ''.join(itertools.repeat("d", data_len))
bx = struct.pack(data_format, *self._data["x"])
by = struct.pack(data_format, *self._data["y"])
execute(
"INSERT INTO " +
"results_add_data (pamhyr_id, result, " +
"type_x, type_y, " +
"legend, unit, data_len, x, y, " +
"scenario) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
self._pamhyr_id, data["result"],
self._data["type_x"], self._data["type_y"],
self._data["legend"], self._data["unit"],
data_len, bx, by, self._owner_scenario
)
return True
class TableData(SQLSubModel):
_sub_classes = []
def __init__(self, id=-1, study=None,
legend="", data=None,
owner_scenario=-1):
super(TableData, self).__init__(
id=id, status=study.status,
owner_scenario=owner_scenario
)
self._study = study
self._legend = legend
self._data = data
@property
def data(self):
return self._data
@classmethod
def _db_create(cls, execute, ext=""):
execute(f"""
CREATE TABLE results_table_data{ext} (
{cls.create_db_add_pamhyr_id()},
result INTEGER NOT NULL,
legend TEXT NOT NULL,
unit TEXT NOT NULL,
data_shape_x INTEGER NOT NULL,
data_shape_y INTEGER NOT NULL,
data_shape_z INTEGER DEFAULT -1,
data BLOB NOT NULL,
{Scenario.create_db_add_scenario()},
{Scenario.create_db_add_scenario_fk()},
FOREIGN KEY(result) REFERENCES results(pamhyr_id),
PRIMARY KEY(pamhyr_id, result, legend, scenario)
)
""")
if ext != "":
return True
return cls._create_submodel(execute)
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
create = False
if major == "0" and int(minor) == 2:
if int(release) < 7 and not create:
cls._db_create(execute)
create = True
return cls._update_submodel(execute, version, data)
@classmethod
def _db_load(cls, execute, data=None):
res = {}
study = data['study']
status = data['status']
scenario = data["scenario"]
result = data["result"]
rid = data["result_pid"]
table = execute(
"SELECT pamhyr_id, " +
"legend, unit, " +
"data_shape_x, data_shape_y, data_shape_z, " +
"data, " +
"scenario " +
"FROM results_table_data " +
f"WHERE scenario = {scenario.id} " +
f"AND result = {rid}"
)
for v in table:
it = iter(v)
pid = next(it)
legend = next(it)
unit = next(it)
data_shape_x = next(it)
data_shape_y = next(it)
data_shape_z = next(it)
data = next(it)
owner_scenario = next(it)
dtype = cls._unit_to_dtype(unit)
np_data = np.frombuffer(data, dtype=dtype)
if data_shape_y == -1:
np_data = np.reshape(np_data, data_shape_x)
elif data_shape_z == -1:
np_data = np.reshape(np_data, (data_shape_x,
data_shape_y))
else:
np_data = np.reshape(np_data, (data_shape_x,
data_shape_y,
data_shape_z))
new_table = cls(study=study,
legend=legend, data=np_data,
owner_scenario=owner_scenario)
res[legend] = new_table
return res
def _db_save(self, execute, data=None):
if self._status.scenario.id != self._owner_scenario:
return
shape_x = -1
shape_y = -1
shape_z = -1
shape = self._data.shape
if len(shape) == 2:
shape_x, shape_y = shape
elif len(shape) == 1:
shape_x, = shape
elif len(shape) == 3:
shape_x, shape_y, shape_z = shape
else:
logger.error(
f"Failed to parse numpy shape: {shape}"
)
execute(
"INSERT INTO " +
"results_table_data (pamhyr_id, result, " +
"legend, unit, " +
"data_shape_x, data_shape_y, data_shape_z, " +
"data, " +
"scenario) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
self._pamhyr_id, data["result"],
self._legend, self._dtype_to_unit(self._data.dtype),
shape_x, shape_y, shape_z,
self._data,
self._owner_scenario
)
return True
@classmethod
def _unit_to_dtype(cls, unit):
t = {
"i32": np.int32, "i64": np.int64,
"u32": np.uint32, "u64": np.uint64,
"f32": np.float32, "f64": np.float64,
}
return t[unit]
def _dtype_to_unit(self, dtype):
t = {
np.dtype(np.int32): "i32", np.dtype(np.int64): "i64",
np.dtype(np.uint32): "u32", np.dtype(np.uint64): "u64",
np.dtype(np.float32): "f32", np.dtype(np.float64): "f64",
}
return t[dtype]
def table(self):
return self._data
def __len__(self):
return len(self._data)
def __getitem__(self, key):
if isinstance(key, tuple):
return self._data[key[0], key[1]]
self._data[key]
class Results(SQLSubModel):
_sub_classes = [River]
_sub_classes = [River, TableData, AdditionalData]
def __init__(self, id=-1, study=None, solver=None,
repertory="", name="0"):
repertory="", name="0", is_ensemble=False):
super(Results, self).__init__(
id=id, status=study.status,
owner_scenario=study.status.scenario.id
@@ -41,20 +346,29 @@ class Results(SQLSubModel):
self._name = name
self._study = study
self._river = River(self._study)
self._river = River(self._study, self)
self._solver = solver
self._repertory = repertory
self._is_ensemble = is_ensemble
self._meta_data = {
# Keep results creation date
"creation_date": datetime.now(),
"study_revision": study.status.version,
"additional_data": [],
"table": {},
}
self._ts_index = {}
if solver is not None:
self.set("solver_type", solver._type)
def is_ensemble(self):
return self._is_ensemble
@property
def date(self):
date = self._meta_data["creation_date"]
@@ -68,6 +382,7 @@ class Results(SQLSubModel):
def study(self):
return self._study
@timer
def set(self, key, value):
self._meta_data[key] = value
@@ -85,6 +400,16 @@ class Results(SQLSubModel):
def get(self, key):
return self._meta_data[key]
def set_timestamp_index(self, index):
self._ts_index = index
def get_timestamp_id(self, ts):
return self._ts_index[ts]
def compute_timestamp_index(self):
for i, ts in enumerate(self._meta_data["timestamps"]):
self._ts_index[ts] = i
def reload(self):
return self._solver.results(
self._study,
@@ -92,6 +417,11 @@ class Results(SQLSubModel):
qlog=None,
)
def bufferize(self, key):
if self.is_valid:
for reach in self._river._reachs:
reach.bufferize(self._meta_data["timestamps"], key)
def timestamps_to_struct(self):
ts = self._meta_data["timestamps"]
sf = ">" + ''.join(itertools.repeat("d", len(ts)))
@@ -177,13 +507,41 @@ class Results(SQLSubModel):
new_results.set("study_revision", revision)
new_results.set("creation_date", creation_date)
data["result_pid"] = pid
data["result"] = new_results
table_data = TableData._db_load(execute, data)
new_results.set("table", table_data)
sf = ">" + ''.join(itertools.repeat("d", nb_timestamps))
ts = struct.unpack(sf, timestamps_bytes)
new_results.set("timestamps", ts)
data["timestamps"] = sorted(ts)
new_results.compute_timestamp_index()
data["parent"] = new_results
new_results._river = River._db_load(execute, data)
new_results.set(
"additional_data",
AdditionalData._db_load(execute, data)
)
# Update global index
i = 0
for reach in new_results._river.reachs:
nb = len(reach.profiles)
reach.set_global_index(range(i, i + nb + 1))
i += nb
if "Z" in table_data:
for ts in data["timestamps"]:
new_results._river.update_water_limits(
ts,
table_data["Z"][new_results.get_timestamp_id(ts), :]
)
yield (solver_type, new_results)
def _db_save_clear(self, execute, solver_type, data=None):
@@ -206,10 +564,26 @@ class Results(SQLSubModel):
f"WHERE scenario = {self._owner_scenario} " +
f"AND result = {pid}"
)
execute(
"DELETE FROM results_table_data " +
f"WHERE scenario = {self._owner_scenario} " +
f"AND result = {pid}"
)
execute(
"DELETE FROM results_add_data " +
f"WHERE scenario = {self._owner_scenario} " +
f"AND result = {pid}"
)
def _is_valid(self):
return "timestamps" in self._meta_data
def _db_save(self, execute, data=None):
if self._status.scenario.id != self._owner_scenario:
return
return True
if not self._is_valid():
return False
pid = self._pamhyr_id
if self._solver is None:
@@ -238,4 +612,19 @@ class Results(SQLSubModel):
data["result"] = self._pamhyr_id
self._river._db_save(execute, data)
tables = self.get("table")
for legend in tables:
tables[legend]._db_save(execute, data)
for add_data in self.get("additional_data"):
add_data._db_save(execute, data)
return True
def new_table_data(self, legend, data):
return TableData(
study=self._study,
legend=legend,
data=data,
owner_scenario=self._owner_scenario
)
+9 -2
View File
@@ -1,5 +1,5 @@
# Results.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,12 +21,13 @@ import os
from copy import deepcopy
from datetime import datetime
from Model.Tools.PamhyrDB import SQLSubModel
from Model.Results.River.RiverAdisTS import River
logger = logging.getLogger()
class Results(object):
class Results(SQLSubModel):
def __init__(self, study=None, solver=None,
repertory="", name="0", type_pol=None):
self._study = study
@@ -50,6 +51,9 @@ class Results(object):
self._phys_var_list = ["C", "G", "M", "D", "L", "N", "R"]
if solver is not None:
self.set("solver_type", solver._type)
@property
def date(self):
date = self._meta_data["creation_date"]
@@ -87,3 +91,6 @@ class Results(object):
self._repertory,
qlog=None,
)
def _db_save(self, execute, data=None):
return False
+94 -33
View File
@@ -1,5 +1,5 @@
# River.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,11 +14,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import types
import struct
import logging
import itertools
import numpy as np
from tools import flatten
from tools import flatten, timer
from functools import reduce
from datetime import datetime
@@ -29,15 +31,17 @@ logger = logging.getLogger()
class Profile(SQLSubModel):
def __init__(self, profile, study):
def __init__(self, profile, study, parent):
super(Profile, self).__init__(
id=-1, status=study.status,
owner_scenario=study.status.scenario.id
)
self._parent = parent
self._study = study
self._profile = profile # Source profile in the study
self._data = {} # Dict of dict {<ts>: {<key>: <value>, ...}, ...}
self._global_index = -1
def __len__(self):
return len(self._data)
@@ -54,15 +58,26 @@ class Profile(SQLSubModel):
def geometry(self):
return self._profile
@property
def global_index(self):
return self._global_index
@global_index.setter
def global_index(self, id):
self._global_index = id
@timer
def set(self, timestamp, key, data):
if timestamp not in self._data:
self._data[timestamp] = {}
self._data[timestamp][key] = data
@timer
def get_ts(self, timestamp):
return self._data[timestamp]
@timer
def get_key(self, key):
res = list(
map(lambda ts: self._data[ts][key],
@@ -70,13 +85,25 @@ class Profile(SQLSubModel):
)
return res
@timer
def get_ts_key(self, timestamp, key):
if timestamp in self._data:
if key in self._data[timestamp]:
return self._data[timestamp][key]
v = self._data[timestamp][key]
# If is a generator, compute value(s)
if isinstance(v, types.GeneratorType):
v = next(v)
self._data[timestamp][key] = v
return v
return None
def has_sediment(self):
def has_sediment_layers(self):
return any(map(lambda ts: "sl" in self._data[ts], self._data))
def has_bedload(self):
return any(map(lambda ts: "sl" in self._data[ts], self._data))
@classmethod
@@ -105,24 +132,14 @@ class Profile(SQLSubModel):
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
create = False
if major == "0" and int(minor) < 2:
cls._db_create(execute)
create = True
if major == "0" and int(minor) == 2:
if int(release) < 1 and not create:
cls._db_create(execute)
create = True
return cls._update_submodel(execute, version, data)
@classmethod
def _db_load(cls, execute, data=None):
new = {}
status = data['status']
parent = data['parent']
study = data['study']
reach = data['reach']
profile = data['profile']
@@ -130,6 +147,8 @@ class Profile(SQLSubModel):
loaded = data['loaded_pid']
timestamps = data['timestamps']
new = cls(profile, study, parent)
values = execute(
"SELECT pamhyr_id, result, key, " +
"len_data, data, scenario " +
@@ -149,12 +168,6 @@ class Profile(SQLSubModel):
data = next(it)
owner_scenario = next(it)
if profile not in new:
new_data = cls(profile, study)
new[profile] = new_data
else:
new_data = new[profile]
if key in ["Z", "Q", "V"]:
sf = ">" + ''.join(itertools.repeat("f", len_data))
len_values = len(values)
@@ -167,11 +180,11 @@ class Profile(SQLSubModel):
)
for timestamp, value in zip(timestamps, values):
new_data.set(timestamp, key, value)
new.set(timestamp, key, value)
if key == "Z":
new_data.update_water_limits(timestamp, value)
new.update_water_limits(timestamp, value)
return list(new.values())
return new
@classmethod
def _db_load_data_sl_format(cls, values, len_data, timestamps):
@@ -263,19 +276,20 @@ class Profile(SQLSubModel):
class Reach(SQLSubModel):
_sub_classes = [Profile]
def __init__(self, reach, study, with_init=True):
def __init__(self, reach, study, parent, with_init=True):
super(Reach, self).__init__(
id=-1, status=study.status,
owner_scenario=study.status.scenario.id
)
self._parent = parent
self._study = study
self._reach = reach # Source reach in the study
self._profiles = []
if with_init:
self._profiles = list(
map(
lambda p: Profile(p, self._study),
lambda p: Profile(p, self._study, self._parent),
reach.profiles
)
)
@@ -286,6 +300,10 @@ class Reach(SQLSubModel):
)
)
self._global_index = (-1, -1)
self._buffers = {}
def __len__(self):
return len(self._profiles)
@@ -305,14 +323,42 @@ class Reach(SQLSubModel):
def profile_mask(self):
return self._profile_mask
@property
def buffers(self):
return self._buffers
def profile(self, id):
return self._profiles[id]
def set_global_index(self, indexs):
self._global_index = (indexs[0], indexs[-1])
for profile, ind in zip(self._profiles, indexs):
profile.global_index = ind
@property
def global_index(self):
return self._global_index
@timer
def set(self, profile_id, timestamp, key, data):
self._profiles[profile_id].set(timestamp, key, data)
def has_sediment(self):
return any(map(lambda profile: profile.has_sediment(), self._profiles))
return any(map(lambda profile: profile.has_sediment_layers(),
self._profiles))
def has_bedload(self):
return any(map(lambda profile: profile.has_bedload(), self._profiles))
def bufferize(self, timestamps, key):
self._buffers[key] = np.zeros((len(timestamps), len(self)))
for i, p in enumerate(self._profiles):
self._buffers[key][:, i] = p.get_key(key)
def update_water_limits(self, timestamp, z_data):
for profile, z in zip(self._profiles, z_data):
profile.update_water_limits(timestamp, z)
@classmethod
def _db_create(cls, execute, ext=""):
@@ -327,12 +373,13 @@ class Reach(SQLSubModel):
reach = data["reach"]
new_reach = cls(
data["reach"], data["study"], with_init=False
data["reach"], data["study"], data["parent"],
with_init=False
)
for i, profile in enumerate(reach.profiles):
data["profile"] = profile
new_reach._profiles += Profile._db_load(execute, data)
new_reach._profiles += [Profile._db_load(execute, data)]
return new_reach
@@ -346,16 +393,19 @@ class Reach(SQLSubModel):
class River(SQLSubModel):
_sub_classes = [Reach]
def __init__(self, study):
def __init__(self, study, parent):
super(River, self).__init__(
id=-1, status=study.status,
owner_scenario=study.status.scenario.id
)
self._study = study
self._parent = parent
# Dict with timestamps as key
self._reachs = []
for i, _ in enumerate(self._study.river.enable_edges()):
self.add(i)
def __len__(self):
return len(self._reachs)
@@ -373,7 +423,7 @@ class River(SQLSubModel):
def add(self, reach_id):
reachs = self._study.river.enable_edges()
new = Reach(reachs[reach_id].reach, self._study)
new = Reach(reachs[reach_id].reach, self._study, self._parent)
self._reachs.append(new)
return new
@@ -386,6 +436,15 @@ class River(SQLSubModel):
)
)
def update_water_limits(self, timestamp, data):
for reach in self._reachs:
ind = reach.global_index
reach.update_water_limits(
timestamp,
data[ind[0]:ind[1]]
)
@classmethod
def _db_create(cls, execute, ext=""):
return cls._create_submodel(execute)
@@ -397,7 +456,9 @@ class River(SQLSubModel):
@classmethod
def _db_load(cls, execute, data=None):
study = data["study"]
new_river = cls(study)
parent = data["parent"]
new_river = cls(study, parent)
for reach in study.river.reachs():
data["reach"] = reach.reach
+1 -1
View File
@@ -1,5 +1,5 @@
# River.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+32 -4
View File
@@ -1,5 +1,5 @@
# River.py -- Pamhyr river model
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -59,6 +59,8 @@ from Model.LateralContributionsAdisTS.LateralContributionsAdisTSList \
import LateralContributionsAdisTSList
from Model.D90AdisTS.D90AdisTSList import D90AdisTSList
from Model.DIFAdisTS.DIFAdisTSList import DIFAdisTSList
from Model.GeoTIFF.GeoTIFFList import GeoTIFFList
from Model.Ensembles.EnsembleList import EnsembleList
from Model.Results.Results import Results
logger = logging.getLogger()
@@ -179,6 +181,9 @@ class RiverNode(Node):
return nodes
def _db_save(self, execute, data=None):
if not self.must_be_saved():
return True
execute(
"INSERT OR REPLACE INTO river_node(" +
"pamhyr_id, deleted, name, x, y, scenario" +
@@ -360,7 +365,7 @@ class RiverReach(Edge):
)
new.enable(enable=enabled)
if deleted:
nd.set_as_deleted()
new.set_as_deleted()
data["reach"] = new
new._reach = Reach._db_load(execute, data)
@@ -376,6 +381,9 @@ class RiverReach(Edge):
return reachs
def _db_save(self, execute, data=None):
if not self.must_be_saved():
return True
execute(
"INSERT OR REPLACE INTO " +
"river_reach(" +
@@ -385,7 +393,7 @@ class RiverReach(Edge):
"VALUES (" +
f"{self.pamhyr_id}, {self._db_format(self.is_deleted())}, " +
f"'{self._db_format(self._name)}', " +
f"{self._db_format(self.is_enable())},"
f"{self._db_format(self.is_enable())}," +
f"{self.node1.pamhyr_id}, {self.node2.pamhyr_id}, " +
f"{self._status.scenario_id}" +
")"
@@ -468,6 +476,8 @@ class River(Graph):
LateralContributionsAdisTSList,
D90AdisTSList,
DIFAdisTSList,
GeoTIFFList,
EnsembleList,
Results
]
@@ -505,6 +515,11 @@ class River(Graph):
self._D90AdisTS = D90AdisTSList(status=self._status)
self._DIFAdisTS = DIFAdisTSList(status=self._status)
self._geotiff = GeoTIFFList(status=self._status)
# Scenario ensemble
self._ensembles = EnsembleList(status=self._status)
self._results = {}
@classmethod
@@ -539,7 +554,7 @@ class River(Graph):
new._nodes = RiverNode._db_load(
execute, data
)
data["nodes"] = new.nodes()
data["nodes"] = new._nodes
data['loaded_pid'] = set()
new._edges = RiverReach._db_load(
@@ -617,6 +632,10 @@ class River(Graph):
new._DIFAdisTS = DIFAdisTSList._db_load(execute, data)
new._geotiff = GeoTIFFList._db_load(execute, data)
new._ensembles = EnsembleList._db_load(execute, data)
return new
def _db_load_results(self, execute, data=None):
@@ -650,6 +669,10 @@ class River(Graph):
objs.append(self._D90AdisTS)
objs.append(self._DIFAdisTS)
objs.append(self._geotiff)
objs.append(self._ensembles)
for solv_type in self.results:
objs.append(self.results[solv_type])
@@ -726,6 +749,7 @@ class River(Graph):
self._BoundaryConditionsAdisTS,
self._LateralContributionsAdisTS,
self._D90AdisTS, self._DIFAdisTS,
self._geotiff, self._ensembles,
]
for solver in self._parameters:
@@ -818,6 +842,10 @@ Last export at: @date."""
def additional_files(self):
return self._additional_files
@property
def geotiff(self):
return self._geotiff
@property
def rep_lines(self):
return self._rep_lines
+128 -37
View File
@@ -17,21 +17,58 @@
# -*- coding: utf-8 -*-
import os
import logging
from tools import logger_exception
from tools import logger_exception, timer, flatten
from Model.Tools.PamhyrDB import SQLSubModel
logger = logging.getLogger()
class Scenario(SQLSubModel):
_id_cnt = 0
_sub_classes = []
tables_with_deleted_column = [
# Adists
"output_rk_adists",
"boundary_condition_adists", "boundary_condition_data_adists",
"lateral_contribution_adists", "lateral_contribution_data_adists",
"initial_conditions_adists", "initial_conditions_adists_spec",
"d90_adists", "d90_adists_spec",
"dif_adists_spec",
"pollutants", "pollutants_characteristics",
# Hydraulic
"additional_files",
"boundary_condition", "boundary_condition_data",
"lateral_contribution", "lateral_contribution_data",
"friction", "stricklers",
"hydraulic_structures",
"hydraulic_structures_basic",
"initial_conditions",
"sedimentary_layer", "sedimentary_layer_layer",
"reservoir", "reservoir_data",
"rep_lines",
"geometry_pointXYZ", "geometry_profileXYZ",
"river_reach", "river_node",
"geotiff", "reservoir", "reservoir_data",
"ensemble",
]
related_tables = tables_with_deleted_column + [
"dif_adists",
"solver_parameter",
"hydraulic_structures_basic_value",
"results", "results_data", "results_add_data",
]
def __init__(self,
id: int = -1,
name: str = "",
description: str = "",
x: int = 0.0, y: int = 0.0,
x: int = 1000.0, y: int = 1000.0,
is_ensemble: bool = False,
revision: int = 0,
parent=None):
super(Scenario, self).__init__()
@@ -41,6 +78,7 @@ class Scenario(SQLSubModel):
self._x, self._y = x, y
self._name = name
self._description = description
self._is_ensemble = is_ensemble
self._revision = revision
self._parent = parent
@@ -63,6 +101,7 @@ class Scenario(SQLSubModel):
y REAL NOT NULL DEFAULT 1000,
name TEXT NOT NULL,
description TEXT NOT NULL,
is_ensemble BOOL DEFAULT FALSE,
revision INTEGER NOT NULL,
parent_id INTEGER REFERENCES scenario(id)
)
@@ -98,6 +137,13 @@ class Scenario(SQLSubModel):
cls._db_create(execute)
cls._db_add_default(execute)
if major == "0" and int(minor) == 2:
if int(release) < 8:
execute(
f"ALTER TABLE scenario " +
"ADD COLUMN is_ensemble BOOL DEFAULT FALSE"
)
return True
@classmethod
@@ -118,7 +164,8 @@ class Scenario(SQLSubModel):
scenarios = {}
table = execute(
"SELECT id, x, y, name, description, revision, parent_id " +
"SELECT id, x, y, name, description, " +
" is_ensemble, revision, parent_id " +
"FROM scenario " +
"ORDER BY id ASC"
)
@@ -130,6 +177,7 @@ class Scenario(SQLSubModel):
x, y = next(it), next(it)
name = next(it)
desc = next(it)
is_ens = next(it)
revi = next(it)
parent = next(it)
@@ -139,7 +187,9 @@ class Scenario(SQLSubModel):
new = cls(
id=id, x=x, y=y,
name=name, description=desc,
revision=revi, parent=parent
is_ensemble=is_ens,
revision=revi,
parent=parent
)
scenarios[id] = new
@@ -149,21 +199,18 @@ class Scenario(SQLSubModel):
if self.is_deleted():
return self.drop_all(execute)
parent = 'NULL'
parent = None
if self.parent is not None:
parent = self.parent._id
execute(
"INSERT OR REPLACE INTO " +
"scenario(id, x, y, name, description, revision, parent_id) " +
"VALUES (" +
f"{self._id}, " +
f"{self.x}, {self.y}, " +
f"'{self._db_format(self.name)}', " +
f"'{self._db_format(self.description)}', " +
f"{self._revision}, " +
f"{parent}" +
")"
"scenario(id, x, y, name, description, " +
" is_ensemble, revision, parent_id) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
self._id, self.x, self.y,
self.name, self.description, self._is_ensemble,
self._revision, parent
)
return True
@@ -171,29 +218,7 @@ class Scenario(SQLSubModel):
def drop_all(self, execute):
execute(f"DELETE FROM scenario WHERE id = {self.id}")
tables = [
# Adists
"output_rk_adists",
"boundary_condition_adists", "boundary_condition_data_adists",
"lateral_contribution_adists", "lateral_contribution_data_adists",
"initial_conditions_adists",
"d90_adists", "dif_adists",
"pollutants", "pollutants_characteristics",
# Hydraulic
"additional_files",
"boundary_condition", "boundary_condition_data",
"lateral_contribution", "lateral_contribution_data",
"friction", "stricklers",
"hydraulic_structures",
"hydraulic_structures_basic", "hydraulic_structures_basic_value",
"initial_conditions",
"sedimentary_layer", "sedimentary_layer_layer",
"reservoir", "reservoir_data",
"rep_lines",
"solver_parameter",
"geometry_pointXYZ", "geometry_profileXYZ",
"river_reach", "river_node",
]
tables = self.related_tables
for table in tables:
execute(
@@ -203,6 +228,67 @@ class Scenario(SQLSubModel):
return True
def get_parent_branch(self):
def aux(scenario, acc):
if scenario is None:
return acc
return aux(scenario.parent, [scenario.id] + acc)
return aux(self, [])
@timer
def clean_deleted_data(self, execute):
tables = self.tables_with_deleted_column
branch = self.get_parent_branch()
all_ids = []
for table in tables:
if self.parent is None:
# This scenario is the default scenario, so we can
# delete all data marked as deleted
execute(
f"DELETE FROM {table} " +
f"WHERE scenario = {self.id} " +
"AND deleted = TRUE"
)
continue
# Select pamhyr_id for each deleted data in this scenario
# who do not exists into parents scenarios
ids = execute(
f"""
SELECT pamhyr_id FROM {table}
WHERE deleted = TRUE
AND scenario = {self.id}
AND pamhyr_id NOT IN (
SELECT pamhyr_id FROM {table}
WHERE scenario IN
({', '.join(map(str, branch[:-1]))})
)
""", fetch_one=False
)
if ids is None or len(ids) == 0:
continue
ids = flatten(ids)
logger.debug(
f"({self.name}) Drop deleted data into '{table}' : {ids}"
)
execute(
f"DELETE FROM {table} " +
f"WHERE scenario = {self.id} " +
"AND pamhyr_id IN " +
f"({', '.join(map(str, ids))})"
)
all_ids += ids
return all_ids
@property
def id(self):
return self._id
@@ -249,6 +335,9 @@ class Scenario(SQLSubModel):
def parent(self):
return self._parent
def is_ensemble(self):
return self._is_ensemble
def set_pos(self, x, y):
self._x = x
self._y = y
@@ -266,6 +355,8 @@ class Scenario(SQLSubModel):
return self.name
if key == "description":
return self.description
if key == "is_ensemble":
return self.is_ensemble()
if key == "parent":
return self.parent
+16 -2
View File
@@ -16,6 +16,8 @@
# -*- coding: utf-8 -*-
from functools import reduce
from tools import logger_exception
from Model.Tools.PamhyrDict import PamhyrModelDict
@@ -55,8 +57,11 @@ class Scenarios(PamhyrModelDict):
return None
def new(self, parent):
new = Scenario(parent=parent)
def new(self, parent, is_ensemble=False):
new = Scenario(
parent=parent,
is_ensemble=is_ensemble
)
self.set(new._id, new)
return new
@@ -78,3 +83,12 @@ class Scenarios(PamhyrModelDict):
self._dict[key].set_as_deleted()
self._status.modified()
def is_leaf(self, scenario):
return not reduce(
lambda acc, s: (
acc or (not s.is_deleted() and s.parent is scenario)
),
self._dict.values(),
False
)
+1 -1
View File
@@ -1,5 +1,5 @@
# Serializable.py -- Pamhyr pickle abstract class
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1,5 +1,5 @@
# SolverParametersList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+14 -1
View File
@@ -1,5 +1,5 @@
# Status.py -- Pamhyr model status class
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@ class StudyStatus(object):
self._status = Status.EDIT
self._scenario = scenario
self._saved = True
self._loading = False
@property
def scenario_id(self):
@@ -86,6 +87,15 @@ class StudyStatus(object):
def is_saved(self):
return self._saved
def is_loading(self):
return self._loading
def start_loading(self):
self._loading = True
def stop_loading(self):
self._loading = False
def save(self):
logger.debug("model status set as saved")
self._saved = True
@@ -97,6 +107,9 @@ class StudyStatus(object):
self._saved = True
def modified(self):
if self._loading:
return
if self._saved:
self.version += 1
+1 -1
View File
@@ -1,5 +1,5 @@
# Stricklers.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# StricklersList.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+133 -15
View File
@@ -1,5 +1,5 @@
# Study.py -- Pamhyr Study class
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,12 +24,22 @@ from datetime import datetime
from tools import timer, timestamp
from functools import reduce
from Model.Tools.PamhyrListExt import PamhyrModelList
from Model.Tools.PamhyrDict import PamhyrModelDict
from Model.Tools.PamhyrDB import SQLModel
from Model.Scenarios import Scenarios
from Model.Scenario import Scenario
from Model.Status import StudyStatus
from Model.Except import NotImplementedMethodeError
from Model.River import River
from Model.Geometry.Reach import Reach
from Model.Ensembles.DistributionList import DistributionList
from Model.HydraulicStructures.HydraulicStructures import (
HydraulicStructure
)
from Model.HydraulicStructures.Basic.HydraulicStructures import (
BasicHS
)
from Checker.Study import *
@@ -37,10 +47,11 @@ logger = logging.getLogger()
class Study(SQLModel):
_version = "0.2.1"
_version = "0.2.8"
_sub_classes = [
Scenario,
DistributionList,
River,
]
@@ -75,6 +86,9 @@ class Study(SQLModel):
self.scenarios = Scenarios(status=self.status)
self.scenarios[0] = s0
self.status.scenario = s0
self._ens_distributions = DistributionList(status=self.status)
self._river = River(status=self.status)
else:
self._init_db_file(filename, is_new=False)
@@ -379,12 +393,19 @@ class Study(SQLModel):
lambda a, s: a or (s.parent is scenario),
new.scenarios.lst,
False
):
) or scenario.is_ensemble():
new.status.set_as_read_only()
data["scenario"] = scenario
data["loaded_pid"] = set()
# Get ensemble distribution
new._ens_distributions = DistributionList._db_load(
sql_exec, data=data
)
data["ens_distributions"] = new._ens_distributions
# Load river data
new._river = River._db_load(
sql_exec, data=data
@@ -445,12 +466,83 @@ class Study(SQLModel):
)
progress()
if self.status.scenario.is_ensemble():
lst = [
self.scenarios, self._ens_distributions,
self._river._ensembles,
]
for solv in self._river._results:
lst.append(self._river._results[solv])
self._save_submodel(
lst, data=progress
)
progress()
self.commit()
return
self._save_submodel(
[self.scenarios, self._river],
[
self.scenarios, self._ens_distributions,
self._river
],
data=progress
)
# Clear DB for current scenario
ids = self.status.scenario.clean_deleted_data(self.execute)
self.memory_clean(ids)
progress()
self.commit()
@timer
def memory_clean(self, ids):
if len(ids) == 0:
return
reach_class = Reach
hs_classes = [HydraulicStructure, BasicHS]
list_classes = set(PamhyrModelList.__subclasses__())
dict_classes = set(PamhyrModelDict.__subclasses__())
def modifier(obj, data):
t = type(obj)
if t is reach_class:
obj._profiles = list(
filter(
lambda el: el.id not in ids,
obj._profiles
)
)
elif t in hs_classes:
obj._data = list(
filter(
lambda el: el.id not in ids,
obj._data
)
)
elif t in dict_classes:
new = {}
for key in obj._dict:
if obj._dict[key].id not in ids:
new[key] = obj._dict[key]
obj._dict = new
elif t in list_classes:
obj._lst = list(
filter(
lambda el: el.id not in ids,
obj._lst
)
)
self.river._data_traversal(
lambda o, d: True, modifier, {}
)
def sql_save_request_count(self, *args, **kargs):
return self._count()
@@ -459,7 +551,10 @@ class Study(SQLModel):
[self.scenarios, self._river]
)
logger.debug(cnt)
return cnt + 7
# HACK: 8 is the number of SQL request do and dont counted in
# submodel save_count (let's count sql execute into the
# '_save' method)
return cnt + 8
def close(self):
"""Close db connection
@@ -485,7 +580,8 @@ class Study(SQLModel):
self.status.scenario = scenario
if reduce(
lambda a, s: a or (s.parent is scenario),
lambda a, s: a or (s.parent is scenario
and not s.is_deleted()),
self.scenarios.lst,
False
):
@@ -508,18 +604,24 @@ class Study(SQLModel):
data = {
"status": self.status,
"loaded_pid": set(),
"scenario": scenario
"scenario": scenario,
"ens_distributions": self._ens_distributions,
}
# Load river data
river = River._db_load(
sql_exec, data=data
)
data["study"] = self
river._db_load_results(sql_exec, data=data)
self.status.start_loading()
try:
# Load river data
river = River._db_load(
sql_exec, data=data
)
data["study"] = self
river._db_load_results(sql_exec, data=data)
finally:
self.status.stop_loading()
self.status.scenario = old_scenario
self._river_scenario_cache[scenario] = river
self.status.scenario = old_scenario
# FIXME: Disable scenario cache to save memory usage
# self._river_scenario_cache[scenario] = river
return river
@@ -588,6 +690,22 @@ class Study(SQLModel):
self.status.set_as_editable()
return new
def create_ensemble_scenario(self, switch=True):
new = self.scenarios.new(
self.status.scenario,
is_ensemble=True
)
new.name = self.status.scenario.name + " (ensemble)"
new.set_pos(self.status.scenario.x + 100,
self.status.scenario.y)
if switch:
self.status.scenario = new
self.status.set_as_editable()
return new
@property
def results(self):
return self._river.results
+24 -3
View File
@@ -1,5 +1,5 @@
# PamhyrDB.py -- Pamhyr abstract model database classes
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -26,6 +26,8 @@ from functools import reduce
from SQL import SQL
from Model.Except import NotImplementedMethodeError
from tools import trace
from Model.Tools.PamhyrID import PamhyrID
logger = logging.getLogger()
@@ -48,11 +50,9 @@ class SQLModel(SQL):
self._cur = self._db.cursor()
if is_new:
logger.info("Create database")
self._create() # Create db
# self._save() # Save
else:
logger.info("Update database")
self._update() # Update db scheme if necessary
# self._load() # Load data
@@ -202,6 +202,8 @@ class SQLSubModel(PamhyrID):
"""
if self._status is None:
return
if self._status.is_loading():
return
self._owner_scenario = self._status.scenario_id
self._status.modified()
@@ -218,6 +220,8 @@ class SQLSubModel(PamhyrID):
"""
if self._status is None:
return
if self._status.is_loading():
return
self._owner_scenario = self._status.scenario_id
self._status.modified()
@@ -297,6 +301,15 @@ class SQLSubModel(PamhyrID):
"""
raise NotImplementedMethodeError(cls, cls._db_update)
@classmethod
def is_table_exists(cls, execute, table):
return any(
execute(
"SELECT name FROM sqlite_master " +
f"WHERE type='table' AND name='{table}'"
)
)
@classmethod
def _db_update_to_0_2_0_set_node_pid(cls, execute, table, nodes):
els = execute(
@@ -311,6 +324,14 @@ class SQLSubModel(PamhyrID):
if node_id == -1:
continue
if node_id not in nodes:
# ⚠️ cas important : probablement déjà migré
logger.warning(
f"node_id {node_id} not in nodes " +
"→ probably already migrated"
)
continue
execute(
f"UPDATE {table} " +
f"SET node = {nodes[node_id]} " +
+4 -1
View File
@@ -1,5 +1,5 @@
# PamhyrDict.py -- Pamhyr abstract dict for model classes
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -97,6 +97,9 @@ class PamhyrModelDict(SQLSubModel):
Nothing
"""
if predicate(self, data):
modifier(self, data)
for key in self._dict:
self._dict[key]\
._data_traversal(predicate, modifier, data)
+4 -1
View File
@@ -1,5 +1,5 @@
# PamhyrList.py -- Pamhyr Abstract List object for the Model
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -100,6 +100,9 @@ class PamhyrModelList(SQLSubModel):
Nothing
"""
if predicate(self, data):
modifier(self, data)
for el in self._lst:
el._data_traversal(predicate, modifier, data)
+5 -2
View File
@@ -1,5 +1,5 @@
# PamhyrList.py -- Pamhyr Abstract List object for the Model
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -107,6 +107,9 @@ class PamhyrModelList(SQLSubModel):
Returns:
Nothing
"""
if predicate(self, data):
modifier(self, data)
for el in self._lst:
el._data_traversal(predicate, modifier, data)
@@ -168,7 +171,7 @@ class PamhyrModelList(SQLSubModel):
lambda x: x[1],
filter(
lambda x: x[0] in indexes,
enumerate(self._lst)
enumerate(self.lst)
)
)
)
+1 -1
View File
@@ -1,5 +1,5 @@
# __init__.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# test_Model.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+6
View File
@@ -56,6 +56,7 @@ class Modules(IterableFlag):
SEDIMENT_LAYER = auto()
ADDITIONAL_FILES = auto()
OUTPUT_RK = auto()
GEOTIFF = auto()
# Results
RESULTS = auto()
@@ -81,6 +82,7 @@ class Modules(IterableFlag):
cls.RESULTS,
cls.WINDOW_LIST,
cls.OUTPUT_RK,
cls.GEOTIFF
]
@classmethod
@@ -99,6 +101,7 @@ class Modules(IterableFlag):
| cls.HYDRAULIC_STRUCTURES
| cls.RESERVOIR
| cls.SEDIMENT_LAYER
| cls.GEOTIFF
)
@classmethod
@@ -114,6 +117,7 @@ class Modules(IterableFlag):
cls.HYDRAULIC_STRUCTURES,
cls.RESERVOIR,
cls.SEDIMENT_LAYER,
cls.GEOTIFF,
]
@classmethod
@@ -129,6 +133,7 @@ class Modules(IterableFlag):
cls.HYDRAULIC_STRUCTURES: "Hydraulic structures",
cls.RESERVOIR: "Reservoir",
cls.SEDIMENT_LAYER: "Sediment layer",
cls.GEOTIFF: "GeoTIFF",
}
def impact(self):
@@ -168,4 +173,5 @@ _impact = {
Modules.HYDRAULIC_STRUCTURES: [],
Modules.RESERVOIR: [],
Modules.SEDIMENT_LAYER: [],
Modules.GEOTIFF: [],
}
+1 -1
View File
@@ -1,5 +1,5 @@
# SQL.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# AScript.py -- Pamhyr abstract script class
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# Hello.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# ListSolver.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# MageMesh.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,5 +1,5 @@
# P3DST.py -- Pamhyr
# Copyright (C) 2023-2025 INRAE
# Copyright (C) 2023-2026 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Loaded 100 of 344 files, more files were not shown because too many files have changed in this diff. Show more