Skip to content

Commit

Permalink
Merge pull request #4 from elnazazmi/main
Browse files Browse the repository at this point in the history
add an upper level to the code dir
  • Loading branch information
atakeigor authored Nov 5, 2024
2 parents f1b6fd6 + 7a905c2 commit d8af521
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 275 deletions.
10 changes: 5 additions & 5 deletions config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NOTE: this config is provided as a TEMPLATE, it should be changed by the user before using it.
[simulation]
name = "syria_new" # name of the simulation.
experiment_path = "cases/" # path where experiment folder should be placed
experiment_path = "WITOIL_iMagine/cases/" # path where experiment folder should be placed
start_datetime = 2021-08-22T03:43:00 # start date of the simulation
sim_length = 24.0 # length of the simulation in HOURS
spill_lat = [35.25] # lat of oil spill (deg N)
Expand All @@ -10,11 +10,11 @@
spill_rate = [27.78] # spill rate TONS/HOUR
slick_age = [0.0] # age of oil slick in HOURS
oil = [28] # either oil api (number) or name (string), e.g. ["Ragusa"]. Please, consider that name must be exact.
area_spill = true
area_spill = false
area_vertex = false # comprehends thre levels of lists. 1st: all slicks. 2nd: individual slick. 3rd: Coordinates of each vertex in each individual slick
multiple_slick = false
advanced_parameters = false # if = true, user must provide parameters.toml file
advanced_parameters_path = "src/parameters.toml" # this path shuld be provided only if "advanced_parameters" is = true
advanced_parameters_path = "WITOIL_iMagine/src/parameters.toml" # this path shuld be provided only if "advanced_parameters" is = true
[download]
download_data = true # = true if data are not provided by the user
download_curr = true # = true : OCE data are downloaded from Copernicus Marine Service
Expand All @@ -29,8 +29,8 @@
delta = [0.75] # default domain length in degrees (applied to both lon/lat), to download or crop data
# note: delta is used only if set_domain = false
[input_files.dtm]
bathymetry_path = "data/gebco/GEBCO_2023.nc" # GEBCO 2023 bathymetry file
coastline_path = "data/gshhs/f/GSHHS_f_L1.shp" # coastline shapefile gshhg
bathymetry_path = "WITOIL_iMagine/data/gebco/GEBCO_2023.nc" # GEBCO 2023 bathymetry file
coastline_path = "WITOIL_iMagine/data/gshhs/f/GSHHS_f_L1.shp" # coastline shapefile gshhg
[input_files.metoce]
oce_data_path = false # to provide if dowload_curr = false
met_data_path = false # to provide if dowload_wind = false
Expand Down
138 changes: 0 additions & 138 deletions download/download_copernicus_parser.py

This file was deleted.

114 changes: 0 additions & 114 deletions download/download_era5_parser.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/download/download_copernicus_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import xarray as xr

# Functions outside this script
from src.utils.utils import *
from WITOIL_iMagine.src.utils.utils import *


def download_copernicus(
Expand Down
6 changes: 3 additions & 3 deletions src/download/download_era5_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import time

# Functions outside this script
from src.utils.utils import *
from WITOIL_iMagine.src.utils.utils import *

def write_cds(token):
"""
Expand Down Expand Up @@ -73,13 +73,13 @@ def get_era5(xmin,xmax,ymin,ymax,start_date,end_date,output_path,output_name):

def process_era5(output_path,output_name):

met = xr.open_mfdataset('data/ERA5/temp*.nc')
met = xr.open_mfdataset('WITOIL_iMagine/data/ERA5/temp*.nc')
met = Utils.rename_netcdf_variables_mdk3(met)

met.to_netcdf(output_name)

#remove the temporary files
subprocess.run([f'rm -rf {output_path}/temp*.nc'],shell=True)
subprocess.run([f'rm -rf {output_path}/temp*.nc'],shell=True)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion src/plot/plot_mdk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def plot_pyngl(
"""
config = self.config
current_folder = os.path.dirname(os.path.abspath(__file__))
path_to_plotspill = 'src/plot/plotngl.py'
path_to_plotspill = 'WITOIL_iMagine/src/plot/plotngl.py'
root_directory = self.root_directory
spill_lon = config["simulation"]["spill_lon"][0]
spill_lat = config["simulation"]["spill_lat"][0]
Expand Down
24 changes: 11 additions & 13 deletions src/preprocessing/preprocessing_mdk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from numpy.typing import NDArray
from datetime import datetime, timedelta, date

from src.utils.utils import Utils
from src.utils.config import Config
from WITOIL_iMagine.src.utils.utils import Utils
from WITOIL_iMagine.src.utils.config import Config

import logging

Expand Down Expand Up @@ -56,9 +56,8 @@ def process_currents(self, oce_path: str = None):
logger.info("Pre processing currents")
lon_min, lon_max, lat_min, lat_max = self.domain
# opening all files in the directory and concatenating them automatically through open_mfdataset
if oce_path is None:
oce_path = f"{self.exp_folder}/oce_files/"
oce_path = os.path.join(oce_path, "*.nc")
oce_path = f"{self.exp_folder}/oce_files/*.nc"

if glob(oce_path) == []:
oce_path = f"{self.exp_folder}/oce_files/*.nc"
concat = xr.open_mfdataset(oce_path, combine="nested", engine="netcdf4")
Expand All @@ -77,9 +76,8 @@ def process_winds(self, met_path: str = None):
logger.info("Pre processing winds")
lon_min, lon_max, lat_min, lat_max = self.domain
# opening all files in the directory and concatenating them automatically through open_mfdataset
if met_path is None:
met_path = f"{self.exp_folder}/met_files/*.nc"
met_path = os.path.join(met_path, "*.nc")
met_path = f"{self.exp_folder}/met_files/*.nc"

if glob(met_path) == []:
met_path = f"{self.exp_folder}/met_files/*.nc"
concat = xr.open_mfdataset(met_path, combine="nested", engine="netcdf4")
Expand Down Expand Up @@ -221,14 +219,14 @@ def process_medslik_memmory_array(self):

med_for = f'{self.exp_folder}/xp_files/medslik_II.for'

subprocess.run([f'cp src/templates/medslik_II_template.for {med_for}'],shell=True)
subprocess.run([f'cp WITOIL_iMagine/src/templates/medslik_II_template.for {med_for}'],shell=True)

# Replacing NMAX in medslik fortran with a python function
Utils.search_and_replace(med_for, 'NMAX', str(nmax))

def configuration_parameters(self):

subprocess.run([f'cp src/templates/config2.txt {self.exp_folder}/xp_files/config2.txt'],shell=True)
subprocess.run([f'cp WITOIL_iMagine/src/templates/config2.txt {self.exp_folder}/xp_files/config2.txt'],shell=True)

def common_grid(self):

Expand Down Expand Up @@ -270,11 +268,11 @@ def write_config_files(self,
print("...config1.txt...")
# Iterating through slicks or doing for single simulation
if separate_slicks == False:
config_file = f"cases/{simname}/xp_files/config1.txt"
config_file = f"WITOIL_iMagine/cases/{simname}/xp_files/config1.txt"
else:
config_file = f"cases/{simname}/xp_files/slick{s_num+1}/config1.txt"
config_file = f"WITOIL_iMagine/cases/{simname}/xp_files/slick{s_num+1}/config1.txt"
subprocess.run(
[f"cp src/templates/config1_template_0.txt {config_file}"], shell=True
[f"cp WITOIL_iMagine/src/templates/config1_template_0.txt {config_file}"], shell=True
)
# adding spill Name - Add slick number if separate slicks
if separate_slicks == False:
Expand Down

0 comments on commit d8af521

Please sign in to comment.