Commit fd95cb15 authored by CEVAER's avatar CEVAER

Added subdirectory (year, day of year) creation

parent 023d4dd8
......@@ -5,6 +5,8 @@ file_path=$7
filename="${file_path##*/}"
filename_no_ext="${filename%.*}"
# TODO put report file in same dir as generated files
file_report_dir="$output_path/report/$filename_no_ext"
mkdir -p "$file_report_dir"
......
......@@ -256,8 +256,13 @@ def extract_write_cyclone_data(dataset, kept_track_points, filename, output_path
if is_full_time:
sel.attrs["measurement_start_date"] = min_time.strftime("%Y-%m-%d %H:%M:%S")
sel.attrs["measurement_stop_date"] = max_time.strftime("%Y-%m-%d %H:%M:%S")
year = str(min_time.year)
doy = min_time.strftime('%j')
else:
sel.attrs["measurement_start_date"] = str(file_date + min_time)
min_date = file_date + min_time
year = min_date.year
doy = min_date.strftime('%j')
sel.attrs["measurement_start_date"] = str(min_date)
sel.attrs["measurement_stop_date"] = str(file_date + max_time)
# Removing attributes
......@@ -289,7 +294,10 @@ def extract_write_cyclone_data(dataset, kept_track_points, filename, output_path
sel.rio.set_spatial_dims('lon', 'lat', inplace=True)
sel.rio.write_crs("epsg:4326", inplace=True)
sel.to_netcdf(os.path.join(output_path, output_filename))
out = os.path.join(output_path, str(year), doy)
os.makedirs(out, exist_ok=True)
sel.to_netcdf(os.path.join(out, output_filename))
def process_file(session, file, output_path, extract_date_func, attrs_to_del, var_to_del, wind_col,
......@@ -299,6 +307,7 @@ def process_file(session, file, output_path, extract_date_func, attrs_to_del, va
filename = os.path.basename(file)
file_date = extract_date_func(filename)
logger.debug(f"File date {file_date}")
track_points = get_track_points_from_database(session, file_date)
logger.debug(f"Number of track point found : {len(track_points)}")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment