Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code optimization and correction #31

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25,518 changes: 12,847 additions & 12,671 deletions notebooks/IndicateursSecheresse/data_processing/data/df_stations.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Mois,Très bas,Bas,Modérément bas,Autour de la normale,Modérément haut,Haut,Très haut
Janvier 2023,1.6178176171099445,2.3844626604548758,4.090739321027698,41.296613001513634,11.582237424072654,8.299424033339232,30.728705942481966
Février 2023,7.948461237104428,10.203282113785749,18.51303704348583,59.115048099943415,2.450702999172942,0.7944108301049058,0.9750576764027337
Mars 2023,7.278822214816412,6.34176942228147,8.980415988708318,37.82517496226304,7.994354158906902,5.934014232224422,25.64544902079944
Avril 2023,3.133138185121631,2.281215302311497,4.839002725345716,42.7112142929242,13.582315534470576,10.519834460482487,22.933279499343897
Mai 2023,2.7254367561420363,1.9293739338444342,4.405795964785004,52.734260112546814,13.656594968726104,8.209642948177487,16.33889531577812
Juin 2023,2.0887516254876464,2.6434492847854356,6.237808842652796,62.90840377113134,9.673683355006501,5.364109232769831,11.08379388816645
Juillet 2023,2.253843572993349,2.816317669581006,7.010203477471433,69.65600268408691,8.399613175709012,3.93929226943496,5.924727150723322
Août 2023,2.2008143807726683,2.28821134174198,5.206078061376502,64.87238057403914,9.164763134372828,4.568477505214023,11.69927500248287
Septembre 2023,3.7487397897249144,3.6170606752669587,8.19496738884431,63.68331172972862,7.569491595169023,4.098512437503858,9.08791638376232
Octobre 2023,9.203476604357661,6.08604198912569,10.507203238480772,52.66301543834584,5.1970472675318495,2.9527324681509706,13.390482994007222
Novembre 2023,0.7285276073619631,0.4944300936390055,1.5337423312883436,28.168388763319342,6.2096383597029385,6.8917500807232805,55.97352276396512
Décembre 2023,1.0294031796688008,0.6304851232754092,1.4224834108466793,20.695090388993755,6.6629045126388915,8.937710404950476,60.621922979625985
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Mois,Très bas,Bas,Modérément bas,Autour de la normale,Modérément haut,Haut,Très haut
Décembre 2022,10.245310245310245,8.152958152958153,17.82106782106782,24.6031746031746,28.354978354978357,7.503607503607504,3.318903318903319
Janvier 2023,18.650217706821483,13.13497822931785,21.6255442670537,20.101596516690854,18.432510885341074,5.2249637155297535,2.8301886792452833
Février 2023,31.921110299488674,19.430241051862673,24.83564645726808,12.783053323593865,6.939371804236669,1.9722425127830532,2.118334550766983
Mars 2023,27.716994894237786,17.943107221006567,24.653537563822027,14.587892049598834,10.795040116703136,1.8234865061998542,2.4799416484318018
Avril 2023,23.482077542062914,14.264813460131675,18.873445501097294,14.923189465983908,14.045354791514264,9.290416971470373,5.120702267739576
Mai 2023,24.02645113886848,13.51947097722263,22.556943423952976,16.458486407053638,14.254224834680382,5.437178545187362,3.7472446730345332
Juin 2023,20.614035087719298,13.669590643274853,26.46198830409357,20.10233918128655,11.988304093567251,4.239766081871345,2.923976608187134
Juillet 2023,21.071953010279003,12.77533039647577,26.87224669603524,19.750367107195302,13.876651982378855,3.450807635829662,2.2026431718061676
Août 2023,20.386904761904763,13.764880952380953,22.470238095238095,17.93154761904762,15.029761904761903,6.770833333333333,3.6458333333333335
Septembre 2023,20.990391722099037,13.155949741315595,20.768662232076863,19.807834441980784,14.042867701404289,6.947524020694752,4.286770140428677
Octobre 2023,21.642363775901767,12.81657712970069,22.947045280122794,20.107444359171144,14.504988488104376,4.22102839600921,3.760552570990023
Novembre 2023,13.046937151949084,7.478122513922036,12.967382657120128,12.092283214001592,14.638027048528244,15.592680986475735,24.184566428003183
Janvier 2023,17.577947114362914,14.38416466802271,25.210237104951577,18.333889917726705,14.399344242387443,5.725735450377972,4.368681502170679
Février 2023,27.43359860313623,19.156509183707733,29.38450690037272,14.771162821933448,6.282529129310634,1.3297068600785735,1.6419865014606627
Mars 2023,27.481100695494405,17.045660719685515,25.700030238887212,13.982461445418808,8.971877834895677,3.4865436951920166,3.3323253704263687
Avril 2023,20.917476938419348,13.961605584642234,24.769384193467964,15.784717028172526,13.01109449015208,6.3544003989030164,5.201321366242833
Mai 2023,21.882629532507462,14.603490369834523,25.219278415769963,17.870814118214426,11.242728396178075,4.903999758869096,4.277059408626458
Juin 2023,19.992463968348666,15.389204634659464,27.36207492071467,18.865199233836783,10.58498445693472,4.377178384149214,3.428894401356486
Juillet 2023,21.022281263208743,15.44290803695429,25.83479258498883,18.81226979047159,11.979952901394842,4.054706841374313,2.8530885816073908
Août 2023,20.03436529707895,14.840382238567509,22.81071956108884,18.744159406746448,13.74310433183613,5.576824525969915,4.250444638712206
Septembre 2023,20.563976469855895,15.04870988826294,23.66709203523297,17.884154502163156,13.439571726477636,4.783840144417815,4.612655233589591
Octobre 2023,23.905734013809667,15.322725908135695,22.7979585709997,17.07595316721705,11.335935154608226,4.157910537376163,5.403782647853498
Novembre 2023,13.034001743679163,8.516004483746418,14.612654128783161,12.750653879686139,13.619379748412005,11.52073732718894,25.946568688504172
Décembre 2023,11.32283899475283,6.778360796587806,12.08383196784191,12.307833931694743,16.665132406640275,14.474209088956396,26.367792813526037
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Mois,Sécheresse extrême,Grande sécheresse,Sécheresse modérée,Situation normale,Modérément humide,Très humide,Extrêmement humide
Janvier 2023,0.018646280067126608,0.7582820560631487,5.329728385853689,85.76045745540432,6.986139598483436,1.1436385107837652,0.003107713344521101
Février 2023,25.41288191577209,14.94632535094963,18.087668593448942,41.553124139829336,0.0,0.0,0.0
Mars 2023,11.39598483435888,6.137733855429175,6.675368264031325,66.54546584623034,8.12667039592268,1.07216110385978,0.04661570016781652
Avril 2023,0.3018625561978163,3.098908156711625,6.827231856133591,71.28131021194605,14.51830443159923,3.7797045600513806,0.1926782273603083
Mai 2023,2.9800899165061017,10.94412331406551,22.52729608220938,63.54849068721901,0.0,0.0,0.0
Juin 2023,21.162491971740526,20.289017341040463,14.678869621066154,38.172768143866406,4.2838792549775215,1.2716763005780347,0.14129736673089274
Juillet 2023,2.3432158617689103,10.065883522903848,16.94946858101809,63.81689352974082,4.944371931133072,1.6315495058735783,0.2486170675616881
Août 2023,8.173286096090496,9.683634781527752,12.179128597178195,46.233451426440425,10.83348871900056,10.236807756852508,2.660202622910063
Septembre 2023,4.139370584457289,12.745664739884393,23.853564547206165,58.25626204238921,0.8991650610147719,0.09633911368015415,0.009633911368015415
Octobre 2023,3.4651003791410275,13.353844241407172,21.657654297967554,60.54447137796009,0.9602834234570203,0.018646280067126608,0.0
Novembre 2023,0.0032113037893384713,0.12202954399486192,0.7707129094412332,28.94990366088632,24.030186255619782,24.595375722543352,21.52858060372511
Décembre 2023,0.0,0.015538566722605507,1.1249922307166387,78.89862639070172,14.25197339797377,4.754801417117285,0.9540679967679782
Binary file not shown.
Binary file modified notebooks/IndicateursSecheresse/data_processing/images/nappes.pdf
Binary file not shown.
Binary file not shown.
53 changes: 13 additions & 40 deletions notebooks/IndicateursSecheresse/data_processing/main.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,24 @@
from base_standard_index import BaseStandardIndex
from datetime import date, timedelta, datetime
from water_tracker import WaterTracker
from water_tracker import WaterTracker1

def main():
# Remplacez 'votre_cle_api' par votre clé API réelle
api_key = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiZWUxMTk3Y2JlMmZlMzY0NGQwOTUyZTZiNzBlZjJlOTU5NzQ4MDFhNWE3MDQ5OTY5OTc0NmNhZjE5MDM5OWFhODJjNWIxMWQxOWQ4NGI5YWQiLCJpYXQiOjE3MDU5OTkwMjYuMjg2NjA0LCJuYmYiOjE3MDU5OTkwMjYuMjg2NjEsImV4cCI6MTcwNzI5NTAyNi4yNzM2NTcsInN1YiI6IjE5MjMwIiwic2NvcGVzIjpbXX0.Cy97gG8bGp-hz9xcVx8GxfRnnk-lVB0bAPhICm9pIgrZUaP3xmGr4yMdmS3H89tCaa88leOMkv0EHoHyn6xYcgFPxI5ZUNvYUpPdpDKi5LwIhs8S5Js6Wc1Dot8J8mvNMcvyQsv1MwQyt0bkaiSEbQD4fsCQn1ic3YvFrsr40r7pclKyLTprbkMAMTO7N9eiyv8AXMbXuVNTEZZpZ2j5d9jCrem07bqAWmsfkXSalL9bRWlXb5uTVRLaGHmE5ReFHjA33dneZYVdiv0iRenctU17WEuhD_GsVgaKkQe80dQOmX5M7ThrVEs-UNokBKOvJzIEm-Bj2OB3ancm3CbpM--WpX47J6aeyhsAGUhWmotgpWn6SVLrriRlDNz_Xj5-8DANudHUG7Hytbzw2PUB413dKTwSTPw_pheXhJt7U65dYT__DwQ-Sk_OkDa_OxVPGOuvryw82ga1RF48dHmyDa0DijQEhhgB5WTqQPd-bfx2jKhGctaCaPvGuDqkfF7joeLEVqGzV9_QAMUROzLKffYvAoxW0A283d7pV90w4j2PxIxrXPK8OVm044Yryvvez_czrS61L_9ScjMKM190qApmqn_D3ReXn7GpkUdE9l09E5gF7gQg4ksncpGETS4LXlNQM35mYKClpDG6BhLBpZqwX-c4_U_N3l-YvoY_vQM"
# Remplacez 'votre_cle_api'. Il peut arriver que la clé ne marche pas. Dans ce cas,
#il fraudra se connecter sur https://api.emi.imageau.eu/doc pour actualiser la clé API.
api_key = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiZGNmNjgwNzEwODk3NzRiNTIxMjQ2NzQ0ZWRhOTMyMWVjYWMyM2Y1MTlkZTNhNWY3NGEzOWM2NmQwMGY1MWYwNWM3MWJlYTg0YzVmNjQzNjAiLCJpYXQiOjE3MDcyOTU2ODUuMjU3NDQ0LCJuYmYiOjE3MDcyOTU2ODUuMjU3NDQ3LCJleHAiOjE3MDg1OTE2ODUuMjUxMTM5LCJzdWIiOiIxOTIzMCIsInNjb3BlcyI6W119.WOJY9Mz1F9F0o-KwvG3xolwfvK0Rv5s-QSKET6pRA6y7PKFkoVT3_0lYXYZ74xOdRClkULTdpMytCV47qQZG1zfk8AmjLaHBApn4L4NX3en1ndXkNvfjgqcJHhn7BVnGSBbkvUe8qORs_k_zeMWEuZ6TpRYzdLi7HQWHkvErE-RZhXctK82YQSVf-bWgIMx2tFovI-n3LydnfMniDKnLkCRHEpm6x_9ilmHBU_NjagHjf8V1VLI6tvxnORjymy129_1Q1iME8sTJNLiRlZv5ZHR0d2TzK_slXyK-OfhgXKCZbv6ILbjXgyTd5RIVSv_IpuFPTsZd4zWVFYpPrVdsWPT4-5k_KcUo1X8UzqQYG__MXFxqRdUBf0z8q7xOkmkulFgTovz2PGXQwmkWGwHf6M_wsjzKuLyqzYXIRC_n1wbHoQ6Q25HCn3P_0clZIUlLkj_thsBnZLh3R09va7XbtHWrtS_xYWeoTRToea8EE9hL1Yp-wSs_Y8lLWJjnDA_bfN_qjaJUy86eCQl3v6WPGcCiB9ezlvNg1_8Ix1uSGasgBy3UY7YNM3_QcgAoKPp5xnnQNcGi3eRXhYqTpc1qNJpIka0f69rblm4_3op2iXbKBm_7ZvYoJfcE6C_UQA6GnZfmLeHRTdotmTG1li89FuyELGAmxR-VUjz7y8oX-K0"

indicateurs = ["nappes", "pluviométrie"]
indicator= ["débit"]


# Créez une instance de la classe WaterTracker
wt = WaterTracker(api_key)
wt1 = WaterTracker1(api_key)


# If you haven't built station data and downloaded all timeseries yet uncomment the following lines to do so
# téléchargez les données
wt.build_stations_data()
wt.download_all_timeseries()
wt1.build_stations_data()
wt1.download_all_timeseries()

for indicateur in indicateurs:
# Comment the following line if you don't want to recalculate standardized indicators on each run
wt.process(indicateur=indicateur)

# Load existing data
wt.load()

# Generate the plot for drought distribution in France
wt.plot_counts_france(indicateur=indicateur)

for indicateur in indicator:
# Calculez les indicateurs nappes, pluie et débit
sgi_result_all_stations = wt.sgi_to_all_stations() #le code est fait pour
spi_result_all_stations = wt.spi_to_all_stations()
result_df_all_stations = wt.apply_galton_law_to_all_stations()
# Affichez le graphique des indicateurs nappes, pluie et débit
wt.plot_level_nappes(sgi_result_all_stations)
wt.plot_level_pluie(spi_result_all_stations)
wt.plot_level_debit(result_df_all_stations)

#wt1.load_timeseries(indicateur=indicateur)


#wt1.apply_galton_law_to_single_station(station_id)


# Appliquer la loi de Galton à toutes les stations
result_df_all_stations=wt1.apply_galton_law_to_all_stations()


# Créer et afficher le graphique
wt1.plot_level_percentage(result_df_all_stations)



if __name__ == "__main__":
Expand Down
Loading
Loading