diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00.O2o.nc new file mode 100644 index 0000000..576c192 Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00_2.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00_2.O2o.nc new file mode 100644 index 0000000..32ac0b0 Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00_2.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00_3.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00_3.O2o.nc new file mode 100644 index 0000000..98187aa Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00_3.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00_4.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00_4.O2o.nc new file mode 100644 index 0000000..805d5f3 Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0115-00:00:00_4.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0215-00:00:00.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0215-00:00:00.O2o.nc new file mode 100644 index 0000000..49fe0ba Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0215-00:00:00.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0315-00:00:00.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0315-00:00:00.O2o.nc new file mode 100644 index 0000000..dd95237 Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0315-00:00:00.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0415-00:00:00.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0415-00:00:00.O2o.nc new file mode 100644 index 0000000..9ddd6bc Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0415-00:00:00.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0515-00:00:00.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0515-00:00:00.O2o.nc new file mode 100644 index 0000000..eca2f61 Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0515-00:00:00.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0615-00:00:00.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0615-00:00:00.O2o.nc new file mode 100644 index 0000000..f2ba93c Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0615-00:00:00.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0715-00:00:00.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0715-00:00:00.O2o.nc new file mode 100644 index 0000000..cba7893 Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0715-00:00:00.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0815-00:00:00.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0815-00:00:00.O2o.nc new file mode 100644 index 0000000..e8462de Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0815-00:00:00.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy0915-00:00:00.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy0915-00:00:00.O2o.nc new file mode 100644 index 0000000..ecf21ff Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy0915-00:00:00.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/ave.yyyy1015-00:00:00.O2o.nc b/Climatologies/MVR/O2_CLIM/ave.yyyy1015-00:00:00.O2o.nc new file mode 100644 index 0000000..48e9528 Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/ave.yyyy1015-00:00:00.O2o.nc differ diff --git a/Climatologies/MVR/O2_CLIM/diff.nc b/Climatologies/MVR/O2_CLIM/diff.nc new file mode 100644 index 0000000..527f477 Binary files /dev/null and b/Climatologies/MVR/O2_CLIM/diff.nc differ diff --git a/Climatologies/MVR/download_data.py b/Climatologies/MVR/download_data.py new file mode 100644 index 0000000..ba4c306 --- /dev/null +++ b/Climatologies/MVR/download_data.py @@ -0,0 +1,16 @@ +import copernicusmarine + +# no more ppn + +copernicusmarine.subset( + dataset_id="cmems_mod_med_bgc_my_4.2km-climatology_P1M-m", + variables=["chl_avg", "chl_std", "no3_avg", "no3_std", "o2_avg", "o2_std"], + minimum_longitude=-5.541666507720947, + maximum_longitude=36.29166793823242, + minimum_latitude=30.1875, + maximum_latitude=45.97916793823242, + start_datetime="1999-01-01T00:00:00", + end_datetime="1999-12-01T00:00:00", + minimum_depth=1.0182366371154785, + maximum_depth=4152.89599609375, +) diff --git a/Climatologies/MVR/launcher.sh b/Climatologies/MVR/launcher.sh new file mode 100755 index 0000000..f857c62 --- /dev/null +++ b/Climatologies/MVR/launcher.sh @@ -0,0 +1,75 @@ +#! /bin/bash + +#SBATCH --job-name=Cl_CMEMS +#SBATCH -N1 +#SBATCH --ntasks-per-node=16 +#SBATCH --time=00:20:00 +#SBATCH --mem=300gb +#SBATCH --account=OGS_test2528 +#SBATCH --partition=g100_meteo_prod +#SBATCH --qos=qos_meteo + +. ../../profile.inc +module load autoload +module load intel/oneapi-2021--binary +module load intelmpi/oneapi-2021--binary +module load mkl/oneapi-2021--binary +module load netcdf/4.7.4--oneapi--2021.2.0-ifort +module load netcdff/4.5.3--oneapi--2021.2.0-ifort +source /g100_work/OGS23_PRACE_IT/COPERNICUS/py_env_3.9.18_new/bin/activate + +INPUTDIR="/g100_scratch/userexternal/gbolzon0/V12C/MVR" +OUTDIR="/g100_scratch/userexternal/gbolzon0/V12C/MVR/OUTPUT" +INPUTFILE=$INPUTDIR/cmems_mod_med_bgc_my_4.2km-climatology_P1M-m_multi-vars_5.54W-36.29E_30.19N-45.98N_1.02-4152.90m_1999-01-01-1999-12-01.nc + +mkdir -p $OUTDIR + +#if [ ! -f "$INPUTFILE" ]; then +# python download_data.py +#else +# echo "File $INPUTFILE already exists. Skipping download." +#fi +MASKFILE="/g100_work/OGS_prodC/OPA/Interim-dev/etc/static-data/MED24_125/meshmask.nc" + +my_prex_or_die "python netcdf_clim_generator.py -i $INPUTFILE -o $OUTDIR -v o2_avg --least_significant_digit 2 -m $MASKFILE" +my_prex_or_die "python netcdf_clim_generator.py -i $INPUTFILE -o $OUTDIR -v no3_avg --least_significant_digit 3 -m $MASKFILE" +my_prex_or_die "python netcdf_clim_generator.py -i $INPUTFILE -o $OUTDIR -v chl_avg --least_significant_digit 4 -m $MASKFILE" +exit 0 + + +OUTPUT_DIR=3D_LINKS +mkdir -p $OUTPUT_DIR + +for YEAR in {2024..2025}; do + # Ciclo sulle variabili CHL, O2, NO3 + for VAR in CHL O2 NO3; do + # Assegna il nome corretto della variabile a vv + if [[ "$VAR" == "CHL" ]]; then + vv="P_l" + elif [[ "$VAR" == "O2" ]]; then + vv="O2o" + else + vv="N3n" + fi + + INPUT_DIR="${VAR}_CLIM" # Supponendo che le cartelle siano CHL_CLIM, O2_CLIM, NO3_CLIM + + # Controlla se la cartella esiste prima di procedere + if [[ -d "$INPUT_DIR" ]]; then + for file in "$INPUT_DIR"/ave.yyyy*15-00:00:00.${vv}.nc; do + # Controlla se il file esiste per evitare errori + [[ -e "$file" ]] || continue + + filename=$(basename "$file") + + MM=${filename:8:2} # Estrai il mese dal nome del file + #echo "Filename: $filename, Estratto MM: $MM" + new_filename="ave.${YEAR}${MM}15-00:00:00.${vv}.nc" + ln -s "$(realpath --relative-to="$OUTPUT_DIR" "$file")" "$OUTPUT_DIR/$new_filename" + + done + fi + done +done + +#o2_std no3_std chl_std diff --git a/Climatologies/MVR/netcdf_clim_generator.py b/Climatologies/MVR/netcdf_clim_generator.py new file mode 100644 index 0000000..69808e8 --- /dev/null +++ b/Climatologies/MVR/netcdf_clim_generator.py @@ -0,0 +1,64 @@ +import xarray as xr +import numpy as np +import argparse +from bitsea.commons.mask import Mask +from bitsea.utilities.argparse_types import existing_dir_path, existing_file_path + + +# Parsing command-line arguments +parser = argparse.ArgumentParser(description="Adjust coordinates in NetCDF files.") +parser.add_argument('-i', '--input', type=existing_file_path, required=True, help="Input NetCDF file") +parser.add_argument('-o', '--outdir', type=existing_dir_path, required=True, help="string for output directory") +parser.add_argument('-v', '--variable', type=str, required=True, choices=['chl_avg', 'no3_avg', 'o2_avg'], help="variable NetCDF file") +parser.add_argument('-m', '--maskfile', type=existing_file_path, required=True, help="meshmask file") +parser.add_argument('-d', '--least_significant_digit', type=int, required=False, default=0, help="least significant digit for compression") +args = parser.parse_args() + +VAR=args.variable + +VARMOD={ + 'chl_avg':'P_l', + 'no3_avg':'N3n', + 'o2_avg':'O2o' +} +varmod=VARMOD[VAR] +if args.least_significant_digit == 0: + least_significant_digit = None +else: + least_significant_digit = args.least_significant_digit + +TheMask = Mask.from_file(args.maskfile) +jpk,jpi,jpj = TheMask.shape + +with xr.open_dataset(args.input) as ds: + var = ds.variables[VAR][:] +fill_value = 1.e+20 + + +for month in range(12): + fileout = args.outdir / f"ave.yyyy{month+1:02d}15-00:00:00.{varmod}.nc" + print(f"Saving to {fileout} with least_significant_digit = {least_significant_digit}", flush=True) + cmems_clim = var[month,:,:,:] + + new_data = np.full(TheMask.shape, fill_value, dtype=np.float32) + new_data[:,:,80:] = cmems_clim.values + + new_ds = xr.Dataset( + {varmod: (["depth", "latitude", "longitude"], new_data)}, + coords={ + "longitude": (["longitude"], TheMask.lon), + "latitude": (["latitude"], TheMask.lat), + "depth": (["depth"], TheMask.zlevels), + } + ) + + new_ds.to_netcdf(fileout, + encoding={varmod:{ + "zlib":True, + "_FillValue": fill_value, + "complevel": 9, + "least_significant_digit": least_significant_digit, + } + } + ) + new_ds.close() \ No newline at end of file