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

Remove script

No longer useful. Replaced by `Inst_eddies/inst_eddies.py`.
parent 5ff1f4bc
No related branches found
No related tags found
No related merge requests found
#!/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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment