Skip to content

Commit d8af521

Browse files
authored
Merge pull request #4 from elnazazmi/main
add an upper level to the code dir
2 parents f1b6fd6 + 7a905c2 commit d8af521

File tree

7 files changed

+21
-275
lines changed

7 files changed

+21
-275
lines changed

config.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# NOTE: this config is provided as a TEMPLATE, it should be changed by the user before using it.
22
[simulation]
33
name = "syria_new" # name of the simulation.
4-
experiment_path = "cases/" # path where experiment folder should be placed
4+
experiment_path = "WITOIL_iMagine/cases/" # path where experiment folder should be placed
55
start_datetime = 2021-08-22T03:43:00 # start date of the simulation
66
sim_length = 24.0 # length of the simulation in HOURS
77
spill_lat = [35.25] # lat of oil spill (deg N)
@@ -10,11 +10,11 @@
1010
spill_rate = [27.78] # spill rate TONS/HOUR
1111
slick_age = [0.0] # age of oil slick in HOURS
1212
oil = [28] # either oil api (number) or name (string), e.g. ["Ragusa"]. Please, consider that name must be exact.
13-
area_spill = true
13+
area_spill = false
1414
area_vertex = false # comprehends thre levels of lists. 1st: all slicks. 2nd: individual slick. 3rd: Coordinates of each vertex in each individual slick
1515
multiple_slick = false
1616
advanced_parameters = false # if = true, user must provide parameters.toml file
17-
advanced_parameters_path = "src/parameters.toml" # this path shuld be provided only if "advanced_parameters" is = true
17+
advanced_parameters_path = "WITOIL_iMagine/src/parameters.toml" # this path shuld be provided only if "advanced_parameters" is = true
1818
[download]
1919
download_data = true # = true if data are not provided by the user
2020
download_curr = true # = true : OCE data are downloaded from Copernicus Marine Service
@@ -29,8 +29,8 @@
2929
delta = [0.75] # default domain length in degrees (applied to both lon/lat), to download or crop data
3030
# note: delta is used only if set_domain = false
3131
[input_files.dtm]
32-
bathymetry_path = "data/gebco/GEBCO_2023.nc" # GEBCO 2023 bathymetry file
33-
coastline_path = "data/gshhs/f/GSHHS_f_L1.shp" # coastline shapefile gshhg
32+
bathymetry_path = "WITOIL_iMagine/data/gebco/GEBCO_2023.nc" # GEBCO 2023 bathymetry file
33+
coastline_path = "WITOIL_iMagine/data/gshhs/f/GSHHS_f_L1.shp" # coastline shapefile gshhg
3434
[input_files.metoce]
3535
oce_data_path = false # to provide if dowload_curr = false
3636
met_data_path = false # to provide if dowload_wind = false

download/download_copernicus_parser.py

Lines changed: 0 additions & 138 deletions
This file was deleted.

download/download_era5_parser.py

Lines changed: 0 additions & 114 deletions
This file was deleted.

src/download/download_copernicus_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import xarray as xr
88

99
# Functions outside this script
10-
from src.utils.utils import *
10+
from WITOIL_iMagine.src.utils.utils import *
1111

1212

1313
def download_copernicus(

src/download/download_era5_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import time
99

1010
# Functions outside this script
11-
from src.utils.utils import *
11+
from WITOIL_iMagine.src.utils.utils import *
1212

1313
def write_cds(token):
1414
"""
@@ -73,13 +73,13 @@ def get_era5(xmin,xmax,ymin,ymax,start_date,end_date,output_path,output_name):
7373

7474
def process_era5(output_path,output_name):
7575

76-
met = xr.open_mfdataset('data/ERA5/temp*.nc')
76+
met = xr.open_mfdataset('WITOIL_iMagine/data/ERA5/temp*.nc')
7777
met = Utils.rename_netcdf_variables_mdk3(met)
7878

7979
met.to_netcdf(output_name)
8080

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

8484

8585
if __name__ == '__main__':

src/plot/plot_mdk3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def plot_pyngl(
192192
"""
193193
config = self.config
194194
current_folder = os.path.dirname(os.path.abspath(__file__))
195-
path_to_plotspill = 'src/plot/plotngl.py'
195+
path_to_plotspill = 'WITOIL_iMagine/src/plot/plotngl.py'
196196
root_directory = self.root_directory
197197
spill_lon = config["simulation"]["spill_lon"][0]
198198
spill_lat = config["simulation"]["spill_lat"][0]

src/preprocessing/preprocessing_mdk3.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from numpy.typing import NDArray
1010
from datetime import datetime, timedelta, date
1111

12-
from src.utils.utils import Utils
13-
from src.utils.config import Config
12+
from WITOIL_iMagine.src.utils.utils import Utils
13+
from WITOIL_iMagine.src.utils.config import Config
1414

1515
import logging
1616

@@ -56,9 +56,8 @@ def process_currents(self, oce_path: str = None):
5656
logger.info("Pre processing currents")
5757
lon_min, lon_max, lat_min, lat_max = self.domain
5858
# opening all files in the directory and concatenating them automatically through open_mfdataset
59-
if oce_path is None:
60-
oce_path = f"{self.exp_folder}/oce_files/"
61-
oce_path = os.path.join(oce_path, "*.nc")
59+
oce_path = f"{self.exp_folder}/oce_files/*.nc"
60+
6261
if glob(oce_path) == []:
6362
oce_path = f"{self.exp_folder}/oce_files/*.nc"
6463
concat = xr.open_mfdataset(oce_path, combine="nested", engine="netcdf4")
@@ -77,9 +76,8 @@ def process_winds(self, met_path: str = None):
7776
logger.info("Pre processing winds")
7877
lon_min, lon_max, lat_min, lat_max = self.domain
7978
# opening all files in the directory and concatenating them automatically through open_mfdataset
80-
if met_path is None:
81-
met_path = f"{self.exp_folder}/met_files/*.nc"
82-
met_path = os.path.join(met_path, "*.nc")
79+
met_path = f"{self.exp_folder}/met_files/*.nc"
80+
8381
if glob(met_path) == []:
8482
met_path = f"{self.exp_folder}/met_files/*.nc"
8583
concat = xr.open_mfdataset(met_path, combine="nested", engine="netcdf4")
@@ -221,14 +219,14 @@ def process_medslik_memmory_array(self):
221219

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

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

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

229227
def configuration_parameters(self):
230228

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

233231
def common_grid(self):
234232

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

0 commit comments

Comments
 (0)