# HG changeset patch # User siwaa # Date 1771242340 0 # Node ID a7463ad6a389217ff156c3ce1a2a1652b31c0dc0 # Parent ecbd096ba43b1a35b54435e9290d38cbb8dbe9d2 "planemo upload for repository https://forgemia.inra.fr/redelac/redelac-toolbox/-/tree/179e64aac208ae8af4d7416a7d5ff4b9da572850/tools/REDELACplanExpander commit 179e64aac208ae8af4d7416a7d5ff4b9da572850-dirty" diff -r ecbd096ba43b -r a7463ad6a389 redelacPlanExpander.py --- 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]) diff -r ecbd096ba43b -r a7463ad6a389 redelacPlanExpander.xml --- 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 @@ - + to expand REDELAC situations according to a plan - docker://registry.forgemia.inra.fr/redelac/redelac-toolbox:latest + docker://registry.forge.inrae.fr/redelac/redelac-toolbox:latest @@ -16,6 +16,7 @@ +