#!/usr/bin/env python3 """Dumps all information on a particular eddy, specified by days_1950 and eddy_index. """ import argparse import shapefile from os import path import pprint import sys sys.path.append(path.join(sys.path[0], "../../Common")) import util_detect_eddies parser = argparse.ArgumentParser() parser.add_argument("directory", help = "containing the three shapefiles") args = parser.parse_args() reply = input("days_1950, eddy_index = ? ").split(",") days_1950 = int(reply[0]) eddy_index = int(reply[1]) readers, d_init, ishape_last = util_detect_eddies.open_shpc(args.directory) # Find ishape: for ishape, rec in enumerate(readers["extremum"].iterRecords()): if rec["days_1950"] == days_1950 and rec["eddy_index"] == eddy_index: break else: sys.exit("Not found") #-- for basename in ["extremum", "outermost_contour", "max_speed_contour"]: filename = path.join(args.directory, basename) shapeRec = readers[basename].shapeRecord(ishape) print("\n", filename, ":") if shapeRec.shape.shapeType == shapefile.NULL: dct = shapeRec.record.as_dict() pprint.pprint(dct) print("null shape") else: pprint.pprint(shapeRec.__geo_interface__)