Skip to content
Snippets Groups Projects
Commit cc442ef0 authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Rename f to factory and file to fname

parent 4035f3c6
No related branches found
No related tags found
No related merge requests found
...@@ -125,25 +125,26 @@ factories = [dict(writers = {}, cell_name = "Anticyclonic_Cell", ...@@ -125,25 +125,26 @@ factories = [dict(writers = {}, cell_name = "Anticyclonic_Cell",
dict(writers = {}, cell_name = "Cyclonic_Cell", cyclone = True, dict(writers = {}, cell_name = "Cyclonic_Cell", cyclone = True,
SHPC = "SHPC_cyclo")] SHPC = "SHPC_cyclo")]
for f in factories: for factory in factories:
file = path.join(f["SHPC"], "extremum") fname = path.join(factory["SHPC"], "extremum")
f["writers"]["extr"] = shapefile.Writer(file, shapeType = shapefile.POINT) factory["writers"]["extr"] = shapefile.Writer(fname,
shapeType = shapefile.POINT)
file = path.join(f["SHPC"], "centroid") fname = path.join(factory["SHPC"], "centroid")
f["writers"]["centroid"] = shapefile.Writer(file, factory["writers"]["centroid"] = shapefile.Writer(fname,
shapeType = shapefile.POINT) shapeType = shapefile.POINT)
file = path.join(f["SHPC"], "outermost_contour") fname = path.join(factory["SHPC"], "outermost_contour")
f["writers"]["outer"] = shapefile.Writer(file, factory["writers"]["outer"] = shapefile.Writer(fname,
shapeType = shapefile.POLYGON) shapeType = shapefile.POLYGON)
file = path.join(f["SHPC"], "max_speed_contour") fname = path.join(factory["SHPC"], "max_speed_contour")
f["writers"]["max_speed"] = shapefile.Writer(file, factory["writers"]["max_speed"] = shapefile.Writer(fname,
shapeType = shapefile.POLYGON) shapeType = shapefile.POLYGON)
define_fields(f["writers"]) define_fields(factory["writers"])
file = path.join(f["SHPC"], "ishape_last.txt") fname = path.join(factory["SHPC"], "ishape_last.txt")
f["writers"]["ishape_last"] = open(file, "w") factory["writers"]["ishape_last"] = open(fname, "w")
# Loop on dates: # Loop on dates:
...@@ -161,15 +162,16 @@ while True: ...@@ -161,15 +162,16 @@ while True:
assert datetime.date.fromordinal(matlab_data["date_num"] - 366) \ assert datetime.date.fromordinal(matlab_data["date_num"] - 366) \
== my_date == my_date
for f in factories: for factory in factories:
write(f["writers"], matlab_data[f["cell_name"]], f["cyclone"]) write(factory["writers"], matlab_data[factory["cell_name"]],
factory["cyclone"])
os.remove("adt.mat") os.remove("adt.mat")
else: else:
print("Missing file:", adt_file) print("Missing file:", adt_file)
for f in factories: for factory in factories:
write(f["writers"], [], f["cyclone"]) write(factory["writers"], [], factory["cyclone"])
my_date += datetime.timedelta(1) my_date += datetime.timedelta(1)
if my_date > final_date: break if my_date > final_date: break
...@@ -184,7 +186,7 @@ nml["grid_nml"] = dict(corner_deg = [matlab_data["X"][0], matlab_data["Y"][0]], ...@@ -184,7 +186,7 @@ nml["grid_nml"] = dict(corner_deg = [matlab_data["X"][0], matlab_data["Y"][0]],
step_deg = [matlab_data["X"][1] - matlab_data["X"][0], step_deg = [matlab_data["X"][1] - matlab_data["X"][0],
matlab_data["Y"][1] - matlab_data["Y"][0]]) matlab_data["Y"][1] - matlab_data["Y"][0]])
for f in factories: for factory in factories:
file = path.join(f["SHPC"], "grid_nml.txt") fname = path.join(factory["SHPC"], "grid_nml.txt")
nml.write(file, force = True) nml.write(fname, force = True)
for k, v in f["writers"].items(): v.close() for k, v in factory["writers"].items(): v.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment