diff --git a/Convert_Matlab/inst_eddies_v6.py b/Convert_Matlab/inst_eddies_v6.py index a31b83507d9f449e346e3f17633a0bbe6f188c3a..adc13d16c7a5c1ca30349dfc2112fc822d26f279 100755 --- a/Convert_Matlab/inst_eddies_v6.py +++ b/Convert_Matlab/inst_eddies_v6.py @@ -172,29 +172,33 @@ else: # There are two factories, one for cyclones and one for anticyclones: factories = [dict(writers = {}, cell_name = "Anticyclonic_Cell", - cyclone = False, SHPC = "SHPC_anti", id = "id_anti_cell"), + cyclone = False, orientation = "Anticyclones", + id = "id_anti_cell"), dict(writers = {}, cell_name = "Cyclonic_Cell", cyclone = True, - SHPC = "SHPC_cyclo", id = "id_cyclo_cell")] + orientation = "Cyclones", id = "id_cyclo_cell")] for factory in factories: - fname = path.join(factory["SHPC"], "extremum") + fname = path.join("SHPC", "Slice_0", factory["orientation"], "extremum") factory["writers"]["extr"] = shapefile.Writer(fname, shapeType = shapefile.POINT) - fname = path.join(factory["SHPC"], "centroid") + fname = path.join("SHPC", "Slice_0", factory["orientation"], "centroid") factory["writers"]["centroid"] \ = shapefile.Writer(fname, shapeType = shapefile.POINT) - fname = path.join(factory["SHPC"], "outermost_contour") + fname = path.join("SHPC", "Slice_0", factory["orientation"], + "outermost_contour") factory["writers"]["outer"] \ = shapefile.Writer(fname, shapeType = shapefile.POLYGON) - fname = path.join(factory["SHPC"], "max_speed_contour") + fname = path.join("SHPC", "Slice_0", factory["orientation"], + "max_speed_contour") factory["writers"]["max_speed"] \ = shapefile.Writer(fname, shapeType = shapefile.POLYGON) define_fields(factory["writers"]) - fname = path.join(factory["SHPC"], "ishape_last.txt") + fname = path.join("SHPC", "Slice_0", factory["orientation"], + "ishape_last.txt") factory["writers"]["ishape_last"] = open(fname, "w") @@ -250,16 +254,8 @@ nml["grid_nml"] = dict(corner_deg = [matlab_data["X"][0], matlab_data["Y"][0]], nlat = matlab_data["Y"].size, step_deg = [matlab_data["X"][1] - matlab_data["X"][0], matlab_data["Y"][1] - matlab_data["Y"][0]]) +fname = path.join("SHPC", "grid_nml.txt") +nml.write(fname, force = True) for factory in factories: - fname = path.join(factory["SHPC"], "grid_nml.txt") - nml.write(fname, force = True) - fname = path.join(factory["SHPC"], "orientation.txt") - - with open(fname, "w") as f: - if factory["cyclone"]: - f.write("cyclones\n") - else: - f.write("anticyclones\n") - for key, v in factory["writers"].items(): v.close()