Commit 60ad0c32 authored by Seneque Colin's avatar Seneque Colin
Browse files

Lines to decomment for creating json files needed for the application

parent 5b0564c8
......@@ -318,7 +318,6 @@ class Scenario :
def write_in_json(self):
'''
*** not used, can be removed/modified ***
Write the scenario in a Json file
'''
data = self.resultat_final
......@@ -343,6 +342,11 @@ class Scenario :
json_str = json.dumps(dict_indices, ensure_ascii=False)
fid_gz.write(json_str.encode('utf-8'))
'''
Decomment for JSON file
with open('./initial_scenario_indices.json', 'w') as outfile:
json.dump(dict_indices, outfile)
'''
'''
These functions returns values of indices of this scenario
......@@ -601,6 +605,12 @@ def EPCI_repartition(best_scenario):
with gzip.GzipFile('./EPCI_repartition.gz','w') as fid_gz:
json_str = json.dumps(list_EPCI_scenario)
fid_gz.write(json_str)
'''
Decomment for JSON file
with open('./EPCI_repartition.json', 'w') as outfile:
json.dump(list_EPCI_scenario, outfile)
'''
......@@ -840,6 +850,12 @@ def MCMC(scenarInitial, nbr_loop, nbr_scenario, nbr_scenario_to_stock, nbr_parce
with gzip.GzipFile('./best_scenario.gz','w') as fid_gz:
json_str = json.dumps(scenario_json)
fid_gz.write(json_str)
'''
Decomment for JSON file
with open('./best_scenario.json', 'w') as outfile:
json.dump(scenario_json, outfile)
'''
if __name__ == '__main__':
# Modifie these values to define how many of each cultures you want in your scenario, the modifications will tends to approach these values
......@@ -883,9 +899,23 @@ if __name__ == '__main__':
# scenarInitial, nbr_loop, nbr_scenario, nbr_scenario_to_stock, nbr_parcelles_a_modifier, cereales, culturesI, fourrages, fruits_legumes, oleagineux, prairies, proteagineux
#scenario_initial = Scenario("./Parcelle_PAT_MCMC.shp",0, cereales, culturesI, fourrages, fruits_legumes, oleagineux, prairies, proteagineux, False, rng)
'''
Decomment for JSON file
with open('./EPCI_repartition_initiale.json', 'w') as outfile:
json.dump(EPCI_repartition_initiale, outfile)
'''
patches = gpd.GeoDataFrame.from_file("../output/PAT_patches/PAT_patches.shp", encoding='utf-8')
indicators = Indicators('MCMC_config.yml', patches)
scenario_initial = Scenario(indicators,"../output/PAT_patches/PAT_patches.shp",0, cereales, culturesI, fourrages, fruits_legumes, oleagineux, prairies, proteagineux, False, rng)
#scenario_initial = Scenario("../output/patches_RiomLimagneVolcans.shp",0, cereales, culturesI, fourrages, fruits_legumes, oleagineux, prairies, proteagineux, False, rng)
scenario_initial.write_indices_in_json()
#MCMC("./Parcelle_PAT_MCMC.shp", 2, 11, 2, nbr_parcelles_a_modifier, cereales, culturesI, fourrages, fruits_legumes, oleagineux, prairies, proteagineux, rng)
'''
Decomment to copy all JSON files required for the application in the localhost folder for JSON
os.system("cp ./best_scenario.json /var/www/html/json/best_scenario.json")
os.system("cp ./EPCI_repartition_initiale.json /var/www/html/json/EPCI_repartition_initiale.json")
os.system("cp ./EPCI_repartition.json /var/www/html/json/EPCI_repartition.json")
os.system("cp ./initial_scenario_indices.json /var/www/html/json/initial_scenario_indices.json")
'''
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment