Mercurial > repos > siwaa > redelac_stics_e
changeset 4:a7463ad6a389 draft
"planemo upload for repository https://forgemia.inra.fr/redelac/redelac-toolbox/-/tree/179e64aac208ae8af4d7416a7d5ff4b9da572850/tools/REDELACplanExpander commit 179e64aac208ae8af4d7416a7d5ff4b9da572850-dirty"
| author | siwaa |
|---|---|
| date | Mon, 16 Feb 2026 11:45:40 +0000 |
| parents | ecbd096ba43b |
| children | 996b8019f5d5 |
| files | redelacPlanExpander.py redelacPlanExpander.xml |
| diffstat | 2 files changed, 87 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/redelacPlanExpander.py Tue May 07 11:45:15 2024 +0000 +++ b/redelacPlanExpander.py Mon Feb 16 11:45:40 2026 +0000 @@ -13,6 +13,12 @@ aclimParHorizonFileName = sys.argv[8] latitudeMailleDriasDFileName= sys.argv[9] expandedStationsFileName = sys.argv[10] +SafranOrDrias = sys.argv[11] == "SAFRAN" + +print( sys.argv[11]) + +print( sys.argv[11] == "SAFRAN") + # 1) reading the base list of USMs @@ -42,18 +48,36 @@ expandedStationsDf = pd.DataFrame() for i, row in planDf.iterrows(): + + print("I") + print(i) + tmpDf = StationsDf safran = int(row['upc'].split('_')[1]) + + print("safran:") + print(safran) + drias = maillesDf[maillesDf["maille_safran"] == safran].reset_index(drop=True)["maille_drias"][0] + print("drias:") + print(drias) + tmpDfBis = tmpDf; for j, rowS in tmpDf.iterrows(): horizon = rowS['Sta_name'].split('_')[1] - tmpDfBis.at[j, 'Sta_name'] = str(drias) + '_' + horizon + '_sta.xml' - tmpDfBis.at[j, 'aclim'] = aclimParHorizonDf[(aclimParHorizonDf['maille_DRIAS'] == drias) & (aclimParHorizonDf['horizon'] == horizon)].reset_index(drop=True)["aclim"][0] - tmpDfBis.at[j, 'latitude'] = latitudeMailleDriasDf[(latitudeMailleDriasDf['maille_DRIAS'] == drias)].reset_index(drop=True)["latitude"][0] + if SafranOrDrias : + tmpDfBis.at[j, 'Sta_name'] = str(safran) + '_' + horizon + '_sta.xml' + + tmpDfBis.at[j, 'aclim'] = aclimParHorizonDf[(aclimParHorizonDf['maille_SAFRAN'] == safran) & (aclimParHorizonDf['horizon'] == horizon)].reset_index(drop=True)["aclim"][0] + tmpDfBis.at[j, 'latitude'] = latitudeMailleDriasDf[(latitudeMailleDriasDf['maille_DRIAS'] == drias)].reset_index(drop=True)["latitude"][0] + else : + tmpDfBis.at[j, 'Sta_name'] = str(drias) + '_' + horizon + '_sta.xml' + + tmpDfBis.at[j, 'aclim'] = aclimParHorizonDf[(aclimParHorizonDf['maille_DRIAS'] == drias) & (aclimParHorizonDf['horizon'] == horizon)].reset_index(drop=True)["aclim"][0] + tmpDfBis.at[j, 'latitude'] = latitudeMailleDriasDf[(latitudeMailleDriasDf['maille_DRIAS'] == drias)].reset_index(drop=True)["latitude"][0] expandedStationsDf = pd.concat([expandedStationsDf, tmpDfBis]) @@ -71,11 +95,21 @@ typeOfRotation = 'GC' for i, row in planDf.iterrows(): + + print("I") + print(i) + tmpDf = USMsDf safran = int(row['upc'].split('_')[1]) drias = maillesDf[maillesDf["maille_safran"] == safran].reset_index(drop=True)["maille_drias"][0] + print("safran:") + print(safran) + + print("drias:") + print(drias) + tmpDf['upc'] = row['upc'] tmpDf['ucs'] = row['ucs'] tmpDf['num_sol'] = row['num_sol'] @@ -88,6 +122,7 @@ tmpDf['nom_sol_sans_point'] = row['nom_sols_PP_dans_USM'] tmpDf['maille_drias'] = drias + tmpDf['maille_safran'] = safran # Updating the id_simu column # alias =CONCATENATE(F2;"-";G2;"_";H2;"-";I2;"-";K2;"-";L2;"-";M2) @@ -100,6 +135,9 @@ tmpDf['code_rotation'].astype(str) + '-' + \ tmpDf['tete_rotation'].astype(str) + '-' + \ tmpDf['horizon '].astype(str) + + + print(tmpDf['id_simu']) # Merging 2 sheets in order to solve the VLOOKUP plantsDf.rename(columns = {'Nom_plante':'culture'}, inplace = True) @@ -119,6 +157,7 @@ tmpDf['annee_fin'].astype(str) + '-' + \ tmpDf['Code_plante'] + print(tmpDf['usm_name']) # Updating the nomsol column # alias =CONCATENATE(G2;"_";H2) @@ -127,27 +166,49 @@ tmpDf['num_sol'].astype(str) + '_' + \ tmpDf['Norg_sols'].astype(str) - - # Updating the fstation column - # alias =CONCATENATE($E2;"_";M2;"_sta.xml") - - tmpDf['fstation'] = \ - tmpDf['maille_drias'].astype(str) + '_' + \ - tmpDf['horizon '].astype(str) + '_sta.xml' + if SafranOrDrias : + # Updating the fstation column + # alias =CONCATENATE($E2;"_";M2;"_sta.xml") - # Updating the fclim1 column - # alias =CONCATENATE($E2;".";YEAR(R2)) + tmpDf['fstation'] = \ + tmpDf['maille_safran'].astype(str) + '_' + \ + tmpDf['horizon '].astype(str) + '_sta.xml' + + # Updating the fclim1 column + # alias =CONCATENATE($E2;".";YEAR(R2)) + + tmpDf['fclim1'] = \ + tmpDf['maille_safran'].astype(str) + '.' + \ + pd.to_datetime(tmpDf['Début'], dayfirst = True).dt.year.astype(str) + + # Updating the fclim2 column + # alias =CONCATENATE($E2;".";YEAR(S2)) + + tmpDf['fclim2'] = \ + tmpDf['maille_safran'].astype(str) + '.' + \ + pd.to_datetime(tmpDf['Fin'], dayfirst = True).dt.year.astype(str) - tmpDf['fclim1'] = \ - tmpDf['maille_drias'].astype(str) + '.' + \ - pd.to_datetime(tmpDf['Début'], dayfirst = True).dt.year.astype(str) - - # Updating the fclim2 column - # alias =CONCATENATE($E2;".";YEAR(S2)) - - tmpDf['fclim2'] = \ - tmpDf['maille_drias'].astype(str) + '.' + \ - pd.to_datetime(tmpDf['Fin'], dayfirst = True).dt.year.astype(str) + else : + # Updating the fstation column + # alias =CONCATENATE($E2;"_";M2;"_sta.xml") + + tmpDf['fstation'] = \ + tmpDf['maille_drias'].astype(str) + '_' + \ + tmpDf['horizon '].astype(str) + '_sta.xml' + + # Updating the fclim1 column + # alias =CONCATENATE($E2;".";YEAR(R2)) + + tmpDf['fclim1'] = \ + tmpDf['maille_drias'].astype(str) + '.' + \ + pd.to_datetime(tmpDf['Début'], dayfirst = True).dt.year.astype(str) + + # Updating the fclim2 column + # alias =CONCATENATE($E2;".";YEAR(S2)) + + tmpDf['fclim2'] = \ + tmpDf['maille_drias'].astype(str) + '.' + \ + pd.to_datetime(tmpDf['Fin'], dayfirst = True).dt.year.astype(str) expandedDf = pd.concat([expandedDf, tmpDf])
--- a/redelacPlanExpander.xml Tue May 07 11:45:15 2024 +0000 +++ b/redelacPlanExpander.xml Mon Feb 16 11:45:40 2026 +0000 @@ -1,11 +1,11 @@ -<tool id="redelacPlanExpander" name="redelacPlanExpander" version="1.0.2"> +<tool id="redelacPlanExpander" name="redelacPlanExpander" version="1.0.3"> <description>to expand REDELAC situations according to a plan</description> <requirements> - <container type="singularity">docker://registry.forgemia.inra.fr/redelac/redelac-toolbox:latest</container> + <container type="singularity">docker://registry.forge.inrae.fr/redelac/redelac-toolbox:latest</container> </requirements> <command detect_errors="aggressive"> <![CDATA[ - python $__tool_directory__/redelacPlanExpander.py ${USMs} ${Liste_plantes} ${REDELACplan} ${mailles} ${USMsExp} ${SuccessionsExp} ${Stations} ${aclimParHorizon} ${latitudeMailleDrias} ${StationsExp} + python $__tool_directory__/redelacPlanExpander.py ${USMs} ${Liste_plantes} ${REDELACplan} ${mailles} ${USMsExp} ${SuccessionsExp} ${Stations} ${aclimParHorizon} ${latitudeMailleDrias} ${StationsExp} ${SafranOrDrias} ]]> </command> <inputs> @@ -16,6 +16,7 @@ <param name="mailles" type="data" format="csv" label="Select mailles files with link between DRIAS and Safran (csv)"/> <param name="aclimParHorizon" type="data" format="csv" label="Select a aclimParHorizon (csv)"/> <param name="latitudeMailleDrias" type="data" format="csv" label="Select a latitudeMailleDrias(csv)"/> + <param name="SafranOrDrias" type="boolean" checked="true" truevalue="SAFRAN" falsevalue="DRIAS" label="To choose Safran or Drias naming"/> </inputs> <outputs> <data format="csv" name="USMsExp" label="USMsSheetExp"/>
