5 from geo_eval
import get_lat_lon_shift, read_file_l1b
6 from scipy.spatial
import ConvexHull
7 from shapely.geometry.polygon
import Polygon
8 from shapely.geometry
import Point
14 coord = np.column_stack((lat.flatten(), lon.flatten()))
15 hull = ConvexHull(coord)
17 for lat_p, lon_p
in zip(coord[hull.vertices, 0], coord[hull.vertices, 1]):
18 points.append((lat_p, lon_p))
19 points.append((coord[hull.vertices, 0][0], coord[hull.vertices, 1][0]))
20 polygon = Polygon(points)
30 with open(feature_file, mode=
'r')
as file:
31 csvFile = csv.DictReader(file)
33 feature_lat =
float(lines[
"featureLat"])
34 feature_lon =
float(lines[
"featureLon"])
35 south =
float(lines[
"south"])
36 north =
float(lines[
"north"])
37 west =
float(lines[
"west"])
38 east =
float(lines[
"east"])
39 point =
Point(feature_lat, feature_lon)
40 if polygon.contains(point):
45 polygon_chip = Polygon([p_0, p_1, p_2, p_3, p_0])
46 if polygon.contains(polygon_chip):
47 feature_names.append(lines[
"filename"])
48 feature_lats.append(feature_lat)
49 feature_lons.append(feature_lon)
53 if __name__ ==
"__main__":
54 parser = argparse.ArgumentParser()
56 "--ifile", help=
"input L1B netcdf file", type=str, required=
True)
58 "--idir", help=
"directory with chips", type=str, required=
True)
60 "--odir", help=
"output directory", type=str, required=
True)
61 parser.add_argument(
'--debug', action=
'store_true')
62 parser.add_argument(
'--no-debug', dest=
'debug', action=
'store_false')
63 parser.set_defaults(debug=
False)
64 if len(sys.argv) == 1:
67 args = parser.parse_args()
72 feature_file = os.path.join(dir_chips,
"chipindex.csv")
75 feature_names = [os.path.join(dir_chips, x)
for x
in feature_names]
76 outfile = os.path.join(args.odir, f
"gcpm-{os.path.basename(l1b_path)}.csv")
78 with open(
"chip_lists.txt",
"w")
as ilist:
79 ilist.write(
'\n'.join(feature_names))
81 l1b_path, feature_names, outfile, debug_mode=args.debug)