diff --git a/loop_shp_tr_append.py b/loop_shp_tr_append.py deleted file mode 100755 index 3b2904a97f6f111a24231fc4d4705664db93c46f..0000000000000000000000000000000000000000 --- a/loop_shp_tr_append.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python3 - -"""Concatenate a series of daily SHP triplet directories, in a given -year, assuming their names are SHP_triplet_%Y_%m_%d. - -This script creates directory sys.argv[1] containing the resulting SHP -triplet. It also creates the file ishape_last.txt in sys.argv[1]. - -""" - -import datetime -import subprocess -from os import path -import os -import shutil -import sys -import shapefile - -os.mkdir(sys.argv[1]) -year = 2006 -my_date = datetime.date(year, 1, 3) -final_date = datetime.date(year, 1, 15) - -# The first day of the year is the base, so there is nothing to -# concatenate, we just copy it: -from_dir = my_date.strftime("SHP_triplet_%Y_%m_%d") -for src in os.scandir(from_dir): shutil.copy(src, sys.argv[1]) - -file = path.join(sys.argv[1], "ishape_last.txt") - -with open(file, "w") as ishape_last: - to_file = path.join(sys.argv[1], "extremum") - with shapefile.Reader(to_file) as shpr: n_shapes = len(shpr) - ishape_last.write(str(n_shapes - 1) + "\n") - my_date += datetime.timedelta(1) - - while my_date <= final_date: - from_dir = my_date.strftime("SHP_triplet_%Y_%m_%d") - - for filename in ["extremum", "max_speed_contour", "outermost_contour"]: - from_file = path.join(from_dir, filename) - to_file = path.join(sys.argv[1], filename) - - for command in ["dbfcat", "shpcat"]: - subprocess.run([command, from_file, to_file], check = True) - - with shapefile.Reader(to_file) as shpr: n_shapes = len(shpr) - ishape_last.write(str(n_shapes - 1) + "\n") - my_date += datetime.timedelta(1)