From 5a9130f37eed8408974a89dbcdc7cccc2a7a79a6 Mon Sep 17 00:00:00 2001 From: Gildas Cambon <gildas.cambon@ird.fr> Date: Fri, 28 Feb 2025 10:18:55 +0100 Subject: [PATCH] Resolve "various update into croco_tools for v2.0.1 " --- Aforc_ERA5/README_ERA5.txt | 2 +- Aforc_ERA5/era5_crocotools_param_my.py | 86 ------------------- CHANGELOG.md | 5 +- Coupling_tools/CROCO/make_grid_from_WRF.m | 9 +- .../copernicusmarine_env.yml | 8 -- Nesting_tools/create_nestedbulk.m | 4 +- Nesting_tools/create_nestedclim.m | 4 +- Nesting_tools/create_nesteddust.m | 4 +- Nesting_tools/create_nestedforcing.m | 4 +- Nesting_tools/create_nestedgrid.m | 4 +- Nesting_tools/create_nestedrestart.m | 4 +- Nesting_tools/get_findgridpos.m | 2 +- .../Copernicus_Marine_Toolbox_installation.md | 45 +++------- Oforc_OGCM/download_glorys_data.sh | 8 +- Oforc_OGCM/get_file_python_mercator.m | 3 +- Preprocessing_tools/create_bryfile_wkb.m | 6 +- Preprocessing_tools/make_grid.m | 6 ++ Preprocessing_tools/make_gshhs_link.m | 36 ++++++++ UTILITIES/mask/ijcoast.m | 12 +++ crocotools_param.m | 11 ++- oct_start.m | 2 +- 21 files changed, 107 insertions(+), 158 deletions(-) delete mode 100644 Aforc_ERA5/era5_crocotools_param_my.py delete mode 100644 Forecast_tools/CopernicusMarineToolbox/copernicusmarine_env.yml create mode 100644 Preprocessing_tools/make_gshhs_link.m diff --git a/Aforc_ERA5/README_ERA5.txt b/Aforc_ERA5/README_ERA5.txt index 78dc96d7..a889315b 100644 --- a/Aforc_ERA5/README_ERA5.txt +++ b/Aforc_ERA5/README_ERA5.txt @@ -9,7 +9,7 @@ Here is a set of matlab and python routines allowing to : 3- ( Optional : If not using ONLINE_BULK capabilities) : create from these converted data at the ERA5 resolution, new CROCO "frc" and/or "blk" files (similar to CFSR ones) interpolated onto the croco grid ##################### ---> Pre-requisite : First the user need to install the ERA5 python API : https://cds.climate.copernicus.eu/api-how-to +--> Pre-requisite : First the user need to install the ERA5 python API : https://cds.climate.copernicus.eu/how-to-api --> Edit the era5_crocotools_param.py parameter file diff --git a/Aforc_ERA5/era5_crocotools_param_my.py b/Aforc_ERA5/era5_crocotools_param_my.py deleted file mode 100644 index c2930362..00000000 --- a/Aforc_ERA5/era5_crocotools_param_my.py +++ /dev/null @@ -1,86 +0,0 @@ -# -# For ERA5 python crocotools parameters list -# -# CAUTION IT MUST BE CONSISTENT with your MATLAB CROCOTOOLS_PARAM.m file in Run directory -# ******************************************************************************* -# U S E R * O P T I O N S -# ******************************************************************************* -# -# General path -# -config_dir = '/local/tmp/3/gcambon/CONFIGS/RUN_V2.0_cforec_LR_DEV/' # must be the same than crocotools_param -config_name = 'Benguela_LR' -# -# Original ERA5 directory -# -era5_dir_raw = config_dir + 'DATA/ERA5_native_' + config_name -# -# Output ERA5 directory -# -era5_dir_processed = config_dir + 'DATA/ERA5_' + config_name -# -# extraction wave variables -# -wave_extract=False # True to extract wave variables -# -# Dates limits -# -year_start = 2005 -month_start = 1 -year_end = 2005 -month_end = 1 -# -# Year origin of time -# -Yorig=2000 -# -# Overlapping days (at the beginning/end of each month) -# -n_overlap = 0 -# -# Request time (daily hours '00/01/.../23') -# -time = '00/01/02/03/04/05/06/07/08/09/10/11/12/13/14/15/16/17/18/19/20/21/22/23' -# -# Request variables (see available at ERA5_variables.json) -variables = ['lsm','tp','strd','ssr','t2m','q','u10','v10'] #note lsm is land_sea_mask -# -# Request area ([north, west, south, east]) -# -ownArea = 0 # 0 if area from a crocotools_param.m file - # 1 if own area - -if ownArea == 0: - # To complete if ownArea==0 - paramFile = config_dir + 'crocotools_param.m' # path the crocotools_param file of the simulation - -else: - # To complete if ownArea==1 - lonmin=7 - lonmax=23 - latmin=-45 - latmax=-20 -# -# Variable names and conversion coefficients -# TP: convert from accumlated m in a hour into kg m-2 s-1 -# -cff_tp=1000./3600. # m in 1 hour -> kg m-2 s-1 -# Heat flux J m-2 in one hour into W m-2 -# -cff_heat=1./3600. # J m-2 in 1 hour -> W m-2 -# Names, conversion coefficients and new units -# -variables = ['lsm' , 'sst' , 'tp' ,'strd' ,'ssr' ,'t2m' ,'q' ,'u10' ,'v10' ] -conv_cff = [1. , 1. , cff_tp ,cff_heat ,cff_heat ,1. ,1. ,1. ,1. ] -units = ['(0-1)', 'K' , 'kg m-2 s-1','W m-2' ,'W m-2' ,'K' ,'kg kg-1','m s-1','m s-1'] - -if wave_extract: - ## append waves variables - wave_var=['swh', 'mwd', 'pp1d' ,'cdww'];variables.extend(wave_var) - wave_conv_cff=[1., 1., 1. , 1.]; conv_cff.extend(wave_conv_cff) - wave_units=['m','Degrees true','s', 'dimensionless']; units.extend(wave_units) - - -# ******************************************************************************* -# E N D U S E R * O P T I O N S -# ******************************************************************************* diff --git a/CHANGELOG.md b/CHANGELOG.md index cda1eb22..e62c6b3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,10 @@ Release changelog are available here : https://gitlab.inria.fr/croco-ocean/croco ## Fixed -- Preprocessing_tools : fix in mexcdf functionality for matlab 20xx versions (in particular matlab 2024), see issue [#50](https://gitlab.inria.fr/croco-ocean/croco_tools/-/issues/50) +- Issue 50 : fix in mexcdf functionality for matlab 20xx versions (in particular matlab 2024) +- Issue 49, 43 : add GSHHS coastline dataset in m_map private directory +- Issue 44 : fix problem in editmask with longitude in 0-360° convention +- Issue 34 : fix redef and endef issue in Nesting tools + some cleaning in nestgui ## Changed diff --git a/Coupling_tools/CROCO/make_grid_from_WRF.m b/Coupling_tools/CROCO/make_grid_from_WRF.m index 413de464..3f221731 100644 --- a/Coupling_tools/CROCO/make_grid_from_WRF.m +++ b/Coupling_tools/CROCO/make_grid_from_WRF.m @@ -67,6 +67,12 @@ disp([' Title: ',CROCO_title]) disp(' ') disp([' Refine coefficient from WRF is : ',num2str(coef)]) +% +% Link the GSHHS coastline private data +% for crude, low, intermediate, high and full resolution +% +make_gshhs_link ; + % % Get the Longitude % @@ -296,7 +302,8 @@ if strcmp(r,'y') else editmask(croco_grd) end - r=input(' Finished with edit mask ? [press enter when finished]','s'); + disp(' Finished with Editmask? [press a key to finalize make_grid]'); + pause; end % close all diff --git a/Forecast_tools/CopernicusMarineToolbox/copernicusmarine_env.yml b/Forecast_tools/CopernicusMarineToolbox/copernicusmarine_env.yml deleted file mode 100644 index eebe6b1d..00000000 --- a/Forecast_tools/CopernicusMarineToolbox/copernicusmarine_env.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: cmt_1.0 -channels: - - conda-forge -dependencies: - - pip - - pip: - - copernicusmarine>=1.0<=2.0 - - python>=3.9,<3.12 \ No newline at end of file diff --git a/Nesting_tools/create_nestedbulk.m b/Nesting_tools/create_nestedbulk.m index 2db1c3ff..bb5b8ed6 100644 --- a/Nesting_tools/create_nestedbulk.m +++ b/Nesting_tools/create_nestedbulk.m @@ -40,7 +40,7 @@ Lp=L+1; Mp=M+1; nw = netcdf(blkname, 'clobber'); -result = redef(nw); +%result = redef(nw); % % Create dimensions @@ -136,7 +136,7 @@ nw{'vwnd'}.long_name = 'v-wind'; nw{'vwnd'}.units = ncchar('meter second-1'); nw{'vwnd'}.units = 'm/s'; -result = endef(nw); +%result = endef(nw); % % Create global attributes diff --git a/Nesting_tools/create_nestedclim.m b/Nesting_tools/create_nestedclim.m index ace52e95..9f38043d 100644 --- a/Nesting_tools/create_nestedclim.m +++ b/Nesting_tools/create_nestedclim.m @@ -82,7 +82,7 @@ Np=N+1; type = 'CLIMATOLOGY file' ; history = 'CROCO' ; ncclim = netcdf(climfile,clobber); -result = redef(ncclim); +%result = redef(ncclim); % % Create dimensions % @@ -306,7 +306,7 @@ ncclim.history = history; % % Leave define mode % -result = endef(ncclim); +%result = endef(ncclim); % [s_rho,Cs_rho,s_w,Cs_w] = scoordinate(theta_s,theta_b,N,hc,vtransform); % diff --git a/Nesting_tools/create_nesteddust.m b/Nesting_tools/create_nesteddust.m index 78d9e852..ffb0ac73 100644 --- a/Nesting_tools/create_nesteddust.m +++ b/Nesting_tools/create_nesteddust.m @@ -37,7 +37,7 @@ close(nc); Lp=L+1; Mp=M+1; nw = netcdf(dustname, 'clobber'); -redef(nw); +%redef(nw); % % Create dimensions % @@ -70,7 +70,7 @@ nw{'dust'}.units = 'nmol Fe m-3'; nw{'dust'}.field = ncchar('Fe Dust Deposition, scalar, series'); nw{'dust'}.field = 'Fe Dust Deposition, scalar, series'; -endef(nw); +%endef(nw); % % Create global attributes diff --git a/Nesting_tools/create_nestedforcing.m b/Nesting_tools/create_nestedforcing.m index 231f9289..2a7c37ce 100644 --- a/Nesting_tools/create_nestedforcing.m +++ b/Nesting_tools/create_nestedforcing.m @@ -39,7 +39,7 @@ close(nc); Lp=L+1; Mp=M+1; nw = netcdf(frcname, 'clobber'); -redef(nw); +%redef(nw); % % Create dimensions % @@ -187,7 +187,7 @@ nw{'swrad'}.positive = 'downward flux, heating'; nw{'swrad'}.negative = ncchar('upward flux, cooling'); nw{'swrad'}.negative = 'upward flux, cooling'; -endef(nw); +%endef(nw); % % Create global attributes diff --git a/Nesting_tools/create_nestedgrid.m b/Nesting_tools/create_nestedgrid.m index de906462..1b4af3c4 100644 --- a/Nesting_tools/create_nestedgrid.m +++ b/Nesting_tools/create_nestedgrid.m @@ -36,7 +36,7 @@ Lp=L+1; Mp=M+1; % nw = netcdf(grdname, 'clobber'); -redef(nw); +%redef(nw); % % Create dimensions % @@ -275,7 +275,7 @@ nw{'mask_psi'}.option_0 = 'land'; nw{'mask_psi'}.option_1 = ncchar('water'); nw{'mask_psi'}.option_1 = 'water'; -endef(nw); +%endef(nw); % % Create global attributes diff --git a/Nesting_tools/create_nestedrestart.m b/Nesting_tools/create_nestedrestart.m index cdc87b27..f785755b 100644 --- a/Nesting_tools/create_nestedrestart.m +++ b/Nesting_tools/create_nestedrestart.m @@ -69,7 +69,7 @@ ncprt=netcdf(parentfile,'nowrite'); type = 'restart file' ; history = 'CROCO' ; ncrst = netcdf(rstfile,clobber); -result = redef(ncrst); +%result = redef(ncrst); % % Create dimensions @@ -312,7 +312,7 @@ ncrst.CPPS=ncprt.CPPS(:); % % Leave define mode % -result = endef(ncrst); +%result = endef(ncrst); % % Fill variables % diff --git a/Nesting_tools/get_findgridpos.m b/Nesting_tools/get_findgridpos.m index 9e0712c7..51e20bed 100644 --- a/Nesting_tools/get_findgridpos.m +++ b/Nesting_tools/get_findgridpos.m @@ -46,7 +46,7 @@ xy=get(gca,'currentpoint'); x=xy(1,1); y=xy(1,2); [lon1,lat1]=m_xy2ll(x,y); -rbbox +rbbox; xy=get(gca,'currentpoint'); x=xy(1,1); y=xy(1,2); diff --git a/Oforc_OGCM/Copernicus_Marine_Toolbox_installation.md b/Oforc_OGCM/Copernicus_Marine_Toolbox_installation.md index 3e99a2e2..7df71c84 100644 --- a/Oforc_OGCM/Copernicus_Marine_Toolbox_installation.md +++ b/Oforc_OGCM/Copernicus_Marine_Toolbox_installation.md @@ -4,50 +4,25 @@ The Copernicus Marine Toolbox is used to download and extract data from the Cope All the instructions can be found here : - * 1) https://help.marine.copernicus.eu/en/collections/4060068-copernicus-marine-toolbox - * 2) https://help.marine.copernicus.eu/en/articles/7970514-copernicus-marine-toolbox-installation +- Installation and update : https://help.marine.copernicus.eu/en/articles/7970514-copernicus-marine-toolbox-installation + +- Use : https://help.marine.copernicus.eu/en/collections/4060068-copernicus-marine-toolbox -Prerequisites: +## Prerequisites: * python version >= 3.9 & <3.12 ---- -## 2 ways to download it: - - 1) typing : - ```console - python -m pip install copernicusmarine - ``` - - - 2) Use of conda/mamba package (replace conda by mamba command below) - - * Install a dedicated environment, by default named cmt_1.0 . First, you need to copy the file copernicusmarine_env.yml from the directory Forecast_tools/CopernicusMarineToolbox/ - - ```console - conda env create -f copernicusmarine_env.yml - ``` - - Note that you can use micromamba instead of mamba to install the python environment - - - Firstly, you need to activate the environment cmt_1.0 : - - ```console - conda activate cmt_1.0 - ``` +## Location +The location of the executable (here after pathCMC) will be found typing : +```console +which copernicusmarine +``` - The location of the executable (here after pathCMC) will be found typing : +Note that the value returned by your terminal here, will be your pathCMC to fill in your crocotools_param.m and download_glorys_data.sh script - ```console - ls $CONDA_PREFIX/bin/copernicusmarine - ``` - Note that the value returned by your terminal here, will be your pathCMC to fill in your - crocotools_param.m and download_glorys_data.sh script ---- ## When it's installed : You will have access to the copernicusmarine executable with various sub-command, very useful to get, extract and download data from the Copernicus Marine Data Store : diff --git a/Oforc_OGCM/download_glorys_data.sh b/Oforc_OGCM/download_glorys_data.sh index 8b20c40a..d3fb6a0a 100755 --- a/Oforc_OGCM/download_glorys_data.sh +++ b/Oforc_OGCM/download_glorys_data.sh @@ -4,9 +4,7 @@ set -e ########################## # python # ====== -# Type: -# python --version -# It should return: "Python 2.7.10+" or "Python 3.4+". +# python version >= 3.9 & <3.12 # # motuclient # ========== @@ -69,9 +67,9 @@ fi ## cmt info if [[ ${kdata} == "DAILY" ]]; then - product_id_reana='cmems_mod_glo_phy_my_0.083_P1D-m' + product_id_reana='cmems_mod_glo_phy_my_0.083_P1Ddeg-m' elif [[ ${kdata} == "MONTHLY" ]]; then - product_id_reana='cmems_mod_glo_phy_my_0.083_P1M-m' + product_id_reana='cmems_mod_glo_phy_my_0.083_P1Mdeg-m' else echo "Please specify what kind of data you want (DAILY or MONTHLY), exit...."; exit 1 fi diff --git a/Oforc_OGCM/get_file_python_mercator.m b/Oforc_OGCM/get_file_python_mercator.m index 1fe41bcf..2a9dc6ea 100644 --- a/Oforc_OGCM/get_file_python_mercator.m +++ b/Oforc_OGCM/get_file_python_mercator.m @@ -54,8 +54,7 @@ command = { sprintf('export PYTHONWARNINGS="ignore"; ') sprintf(' -y %f -Y %f',geom(3),geom(4)) sprintf(' -z %f -Z %f',geom(5),geom(6)) sprintf(' -o ./') - sprintf(' -f %s',outname) - sprintf(' --force-download')}; + sprintf(' -f %s',outname)}; if isa(vars,'cell') for k =1:size(vars,2) diff --git a/Preprocessing_tools/create_bryfile_wkb.m b/Preprocessing_tools/create_bryfile_wkb.m index e26bade2..1320ede3 100644 --- a/Preprocessing_tools/create_bryfile_wkb.m +++ b/Preprocessing_tools/create_bryfile_wkb.m @@ -58,9 +58,9 @@ M=Mp-1; % Create the boundary file % type = 'WKB BOUNDARY file' ; -history = 'ROMS' ; +history = 'CROCO' ; nc = netcdf(brywkbname,clobber); -result = redef(nc); +%result = redef(nc); % % Create dimensions % @@ -235,7 +235,7 @@ nc.history = history; % % Leave define mode % -result = endef(nc); +%result = endef(nc); % nc{'tstart'}(:) = min([min(time) min(time) min(time)]); nc{'tend'}(:) = max([max(time) max(time) max(time)]); diff --git a/Preprocessing_tools/make_grid.m b/Preprocessing_tools/make_grid.m index ac269281..939048cf 100644 --- a/Preprocessing_tools/make_grid.m +++ b/Preprocessing_tools/make_grid.m @@ -51,6 +51,12 @@ disp([' Title: ',CROCO_title]) disp(' ') disp([' Resolution: 1/',num2str(1/dl),' deg']) +% +% Link the GSHHS coastline private data +% for crude, low, intermediate, high and full resolution +% +make_gshhs_link ; + % % Choose interactive tool for making grid (rotated grid) % diff --git a/Preprocessing_tools/make_gshhs_link.m b/Preprocessing_tools/make_gshhs_link.m new file mode 100644 index 00000000..11e10b49 --- /dev/null +++ b/Preprocessing_tools/make_gshhs_link.m @@ -0,0 +1,36 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Link the GSHHS datasets : coastline (+ borders + rivers) +% at crude, low, intermediate, high and full resolution +% +% +% Updated February 2025 by Gildas Cambon +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +crocotools_param ; +warning off ; +isoctave=exist('octave_config_info'); + +r = 'n'; + +if (isoctave == 0) + disp(' ') + r = input([' Do you want to link the GSHHS data coastlines (+ borders and rivers) ? : ', COASTFILE_DIR, ... + '\n into m_map1.x private directory of CROCOTOOLS : ', CROCOTOOLS_dir, ... + 'UTILITIES/m_map1.4h/private/? y/[n] : '], 's'); +end + +if strcmp(r, 'y') + % + disp('') + disp([' Note : by default the m_map version 1.4h is considered.', ... + ' Adapt if needed with the version of m_map you use (1.4f, 1.4g, ..)']) + disp('...') + + if (isoctave == 0) + eval(['!ln -sf ', COASTFILE_DIR, '* ', CROCOTOOLS_dir, 'UTILITIES/m_map1.4h/private/']) + else + eval(['ln -sf ', COASTFILE_DIR, '* ', CROCOTOOLS_dir, 'UTILITIES/m_map1.4h/private/']) + end +end \ No newline at end of file diff --git a/UTILITIES/mask/ijcoast.m b/UTILITIES/mask/ijcoast.m index a562c6ce..f93af4e8 100644 --- a/UTILITIES/mask/ijcoast.m +++ b/UTILITIES/mask/ijcoast.m @@ -53,6 +53,18 @@ load(Cname); Clon=lon; Clat=lat; +%------------------------------------------------------------------------ +% Check if model is in -180 - 180 convention or in 0 - 360 convention +%------------------------------------------------------------------------- +indrlon180 = find(rlon > 180) ; +if ~isempty(indrlon180), % lon in 0 - 360° convention + disp('Switch from 0-360 to -180-180 for lon convention') + disp(' ') + rlon_new = mod(rlon + 180, 360) - 180; + rlon = rlon_new ; +end + + %----------------------------------------------------------------------- % Extract need coasline data. %----------------------------------------------------------------------- diff --git a/crocotools_param.m b/crocotools_param.m index a3538d7a..8b310ce1 100644 --- a/crocotools_param.m +++ b/crocotools_param.m @@ -194,6 +194,13 @@ topofile = [DATADIR,'Topo/etopo2.nc']; % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % +% +% GSHHS coastline user : add path to gshhs native private data) +% +COASTFILE_DIR = [DATADIR,'gshhs/']; +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % 3 - Surface forcing parameters % used by make_forcing.m and by make_bulk.m % @@ -456,9 +463,9 @@ if strcmp(OGCM,'mercator') % ======================== kdata='MONTHLY' ; % DAILY or MONTHLY if strcmp(kdata,'DAILY') - product_id='cmems_mod_glo_phy_my_0.083_P1D-m'; + product_id='cmems_mod_glo_phy_my_0.083deg_P1D-m'; elseif strcmp(kdata,'MONTHLY') - product_id='cmems_mod_glo_phy_my_0.083_P1M-m'; + product_id='cmems_mod_glo_phy_my_0.083deg_P1M-m'; else disp('Please specify what kind of data you want (DAILY or MONTHLY)') end diff --git a/oct_start.m b/oct_start.m index efc2538b..d16ae96d 100644 --- a/oct_start.m +++ b/oct_start.m @@ -47,7 +47,7 @@ addpath([myutilpath,'m_map1.4h']) addpath([myutilpath,'air_sea']) addpath([myutilpath,'mask']) % -% ROMSTOOLS directories +% CROCOTOOLS directories % addpath([tools_path,'Aforc_CFSR']) addpath([tools_path,'Aforc_ERA5']) -- GitLab