Skip to content

Commit

Permalink
Fixed description of All files;
Browse files Browse the repository at this point in the history
Delete cell_del_empty.m,
	   char_to_logical.m,
	   isexist_var.m,
	   split_dir.m;
Rename split_path.m --> del_separator.m
  • Loading branch information
ChristmasZCY committed Nov 22, 2023
1 parent cddd505 commit cb1e7b6
Show file tree
Hide file tree
Showing 87 changed files with 414 additions and 600 deletions.
36 changes: 18 additions & 18 deletions Configurefiles/Post_fvcom.conf
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@
# *******************
ModelCasename = forecast # fvcom model case name
OutputRes = _global_5 # output file suffix
Switch_temp = .True. # whether to deal with temperature
Switch_salt = .True. # whether to deal with salinity
Switch_u = .True. # whether to deal with u current
Switch_v = .True. # whether to deal with v current
Switch_w = .True. # whether to deal with w current
Switch_adt = .True. # whether to deal with adt
Switch_aice = .True. # whether to deal with aice
Switch_ph = .True. # whether to deal with ph ---> O3_pH
Switch_no3 = .True. # whether to deal with no3 ---> N3_n
Switch_pco2 = .True. # whether to deal with pCO2 ---> O3_pCO2
Switch_chlo = .True. # whether to deal with chlorophyll ---> Chl_T=P1_Chl+P2_Chl+P3_Chl+P4_Chl
Switch_warningtext = .True. # whether to print warning text
Switch_daily_1hour = .True. # whether to calculate daily time need to minus 1 hour
Switch_erosion = .True. # whether to erosion the coastline
Switch_vertical_mask = .True. # whether to mask the data where depth is larger than the depth of the grid
Switch_out_std_level = .True. # whether to output standard depth
Switch_out_sgm_level = .True. # whether to output sigma depth
Switch_temp = .TRUE. # whether to deal with temperature
Switch_salt = .TRUE. # whether to deal with salinity
Switch_u = .TRUE. # whether to deal with u current
Switch_v = .TRUE. # whether to deal with v current
Switch_w = .TRUE. # whether to deal with w current
Switch_adt = .TRUE. # whether to deal with adt
Switch_aice = .TRUE. # whether to deal with aice
Switch_ph = .TRUE. # whether to deal with ph ---> O3_pH
Switch_no3 = .TRUE. # whether to deal with no3 ---> N3_n
Switch_pco2 = .TRUE. # whether to deal with pCO2 ---> O3_pCO2
Switch_chlo = .TRUE. # whether to deal with chlorophyll ---> Chl_T=P1_Chl+P2_Chl+P3_Chl+P4_Chl
Switch_warningtext = .TRUE. # whether to print warning text
Switch_daily_1hour = .TRUE. # whether to calculate daily time need to minus 1 hour
Switch_erosion = .TRUE. # whether to erosion the coastline
Switch_vertical_mask = .TRUE. # whether to mask the data where depth is larger than the depth of the grid
Switch_out_std_level = .TRUE. # whether to output standard depth
Switch_out_sgm_level = .TRUE. # whether to output sigma depth


# *******************
Expand Down Expand Up @@ -116,4 +116,4 @@ ESMF_RegridMethod = bilinear
# netCDF Parameters (optional)
# *******************
P_Source = 147-ERSEM_Global
P_Version = 3.0
P_Version = 3.0
17 changes: 5 additions & 12 deletions Contents.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
% Mbaysalt_toolbox (Author: Christmas, Dovelet, Qidi Ma)
% Version 0.1 2023-03-01
% Version 1.0 2023-10-18
% Version 0.1 2023-03-01 (Created by Christmas, Dovelet, Qidi Ma)
% Version 1.0 2023-10-18 (Fixed by Christmas)
% Version 2.0 2023-11-22 (Fixed by Christmas)
%
% This toolbox is used to postpocess model data and draw pictures.
% The model data is from original FVCOM, original NEMURO, Standard WAVE WATCH III, Standard WRF, and so on.
Expand All @@ -9,17 +10,16 @@
% Toolbox contents
%
% Contents.m - This file
% Mainpath.m - Set main path for toolbox
%
%
% Infunctions - Internal functions for drawing pictures
% =================================================================================================================
% cell_del_empty.m - Delete empty cell
% char_to_logical.m - Convert char to logical
% del_quotation.m - Delete quotation from a string
% del_separator.m - Delete the last separator from a path
% grep.m - Grep something from a file
% input_yn.m - Check input yes or no
% is_number.m - Check if a string is a number with regexp
% isexist_var.m - Check whether assigned variable, if not, assign default value
% json_load.m - Load json file with matlab builtin function or jsonlab
% json_to_struct.m - Convert json to struct
% KeyValue2Struct.m - Convert key-value to struct
Expand All @@ -31,8 +31,6 @@
% read_conf.m - Read config file from Configfiles
% replace_para.m - Replace parameters in a string or struct
% rmfiles.m - Delete files or directories
% split_dir.m - Split directory from a file
% split_path.m - Delete the last '/' from a path
%
%
% Prefunctions - Prefunctions for drawing pictures
Expand Down Expand Up @@ -108,11 +106,6 @@
% make_domain_ll.m - Read and make grid from wrf2fvcom domain file
%
%
% Mainfunctions - Functions for drawing pictures
% =================================================================================================================
% Mainpath.m - Set main path for toolbox
%
%
% Gridfunctions - Functions for model grid
% =================================================================================================================
% read_GMT_to_cst.m - Transform GMT/ACSII Coastline data imported by GEODAS to SMS's cst format
Expand Down
8 changes: 3 additions & 5 deletions Gridfunctions/read_2dm_to_msh.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
function mshFile = read_2dm_to_msh(varargin)
% =================================================================================================================
% discription:
% read 2dm file to msh file for Wave Watch III
% =================================================================================================================
% parameter:
% Parameter:
% varargin: optional parameters
% relpaced_lt_depth: replace the point depth < relpaced_lt_depth to relpaced_lt_depth || required: False || type: double || format: 0.5
% file: 2dm file path || required: False || type: char || format: ./Sanao_Z.2dm
% save_path: save path || required: False || type: char || format: /Users/christmas/Desktop/
% read_method: method of read || required: False || type: char || format: Christmas or Siqi
% =================================================================================================================
% example:
% Example:
% read_2dm_to_msh()
% read_2dm_to_msh(0.5)
% read_2dm_to_msh(0.5,'file','ECS6.2dm')
Expand All @@ -34,7 +32,7 @@
relpaced_lt_depth = [];
end

save_path = split_path(save_path);
save_path = del_separator(save_path);

%% read 2dm file
[~,name,suffix]=fileparts(file);
Expand Down
8 changes: 3 additions & 5 deletions Gridfunctions/read_2dm_to_website.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
function read_2dm_to_website(varargin)
% =================================================================================================================
% discription:
% read 2dm file and write to website format
% =================================================================================================================
% parameter:
% Parameter:
% Global: whether is global grid || required: False || type: logical || format: 'Global'
% =================================================================================================================
% example:
% Example:
% read_2dm_to_website()
% read_2dm_to_website('Global')
% =================================================================================================================
Expand All @@ -17,7 +15,7 @@ function read_2dm_to_website(varargin)
osprints('INFO',file);
[~,name,~]=fileparts(file);
save_path = read_conf('Grid_functions.conf','save_path');
save_path = split_path(save_path);
save_path = del_separator(save_path);

f = f_load_grid(file);

Expand Down
69 changes: 33 additions & 36 deletions Gridfunctions/read_GMT_to_cst.m
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
function read_GMT_to_cst(fin, fout, varargin)
% =================================================================================================================
% discription:
% Transform GMT/ACSII Coastline data imported by GEODAS to SMS's cst format
% 将GEODAS导入的GMT/ACSII岸线数据转换为SMS的cst格式
% =================================================================================================================
% parameter:
% Parameter:
% fin: input file || required: True || type: string || format: 'D:\data\coastline.dat'
% fout: output file || required: True || type: string || format: 'D:\data\coastline.cst'
% =================================================================================================================
% example:
% GMT2cst('D:\data\coastline.dat','D:\data\coastline.cst')
% =================================================================================================================
% History:
% Update:
% 2023-10-17: Created, by Zetao WU;
% 2023-10-18: Modified to a function, by Christmas;
% =================================================================================================================
% Example:
% GMT2cst('D:\data\coastline.dat','D:\data\coastline.cst')
% =================================================================================================================


data = readmatrix(strcat(fin));
[row,~] = find(isnan(data(:,1)));
temp = [];
dd = row(1)-1;
temp = [temp;dd];
for i = 2:length(row)
dd = row(i)-row(i-1)-1;
data = readmatrix(strcat(fin));
[row,~] = find(isnan(data(:,1)));
temp = [];
dd = row(1)-1;
temp = [temp;dd];
end
dd = length(data)-row(length(row));
temp = [temp;dd];
data(row,:) = [];%删除nan
fidID=fopen(strcat(fout),'w');%建立文件
%写入头文件
fprintf(fidID,'%s\n','COAST');
fprintf(fidID,'%i\n',length(temp));
%写入第一个岸线
fprintf(fidID,'%i %i\n',temp(1),0);
for j = 1:temp(1)
fprintf(fidID,'%i %i\n',data(j,:));
end
% 循环写入中间岸线
for i=2:length(temp)
fprintf(fidID,'%i %i\n',temp(i),0);% 保存
for j = 1:temp(i)
ad = sum(temp(1:i-1));
fprintf(fidID,'%i %i\n',data(ad+j,:));
for i = 2:length(row)
dd = row(i)-row(i-1)-1;
temp = [temp;dd];
end
end
fclose(fidID);
dd = length(data)-row(length(row));
temp = [temp;dd];
data(row,:) = [];%删除nan
fidID=fopen(strcat(fout),'w');%建立文件
%写入头文件
fprintf(fidID,'%s\n','COAST');
fprintf(fidID,'%i\n',length(temp));
%写入第一个岸线
fprintf(fidID,'%i %i\n',temp(1),0);
for j = 1:temp(1)
fprintf(fidID,'%i %i\n',data(j,:));
end
% 循环写入中间岸线
for i=2:length(temp)
fprintf(fidID,'%i %i\n',temp(i),0);% 保存
for j = 1:temp(i)
ad = sum(temp(1:i-1));
fprintf(fidID,'%i %i\n',data(ad+j,:));
end
end
fclose(fidID);

end

22 changes: 10 additions & 12 deletions Gridfunctions/read_gebco_to_sms.m
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
function read_gebco_to_sms(res)
% =================================================================================================================
% discription:
% read gebco file and write to xyz file, res=1 means 1/240 degree, res=2 means 1/120 degree and so on
% =================================================================================================================
% parameter:
% Parameter:
% res: resolution of gebco file || required: True || type: int || format: 3
% =================================================================================================================
% example:
% Example:
% read_gebco_to_sms(2)
% =================================================================================================================

!clear
file = split_dir(grep("Grid_functions.conf","gebcoNCfile"));
lon1 = str2double(split_dir(grep("Grid_functions.conf","lon_west")));
lon2 = str2double(split_dir(grep("Grid_functions.conf","lon_east")));
lat1 = str2double(split_dir(grep("Grid_functions.conf","lat_south")));
lat2 = str2double(split_dir(grep("Grid_functions.conf","lat_north")));
xyz_name = split_dir(grep("Grid_functions.conf","xyz_name"));
Outpath_dir = split_dir(grep("Grid_functions.conf","save_path"));
para_conf = read_conf("Grid_functions.conf");
file = para_conf.gebcoNCfile;
lon1 = para_conf.lon_west;
lon2 = para_conf.lon_east;
lat1 = para_conf.lat_south;
lat2 = para_conf.lat_north;
xyz_name = para_conf.xyz_name;
Outpath_dir = para_conf.save_path;

xyz_file = fullfile(Outpath_dir,xyz_name);
Lon = [lon1 lon2];
Expand Down
8 changes: 3 additions & 5 deletions Infunctions/KeyValue2Struct.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
function varargout = KeyValue2Struct(key,value,varargin)
% =================================================================================================================
% discription:
% Convert key and value to struct
% =================================================================================================================
% parameter:
% Parameter:
% key: key of struct || required: True || type: string || format: {"key1","key2"}
% value: value of struct || required: True || type: string || format: {"value1","value2"}
% varargin: key || required: False|| type: string || format: "key1"
% varargout: value of varargin || required: False|| type: string || format: "value1"
% varargout: struct || required: False|| type: struct || format: struct('key1','value1','key2','value2')
% =================================================================================================================
% example:
% Example:
% Struct = KeyValue2Struct(key,value);
% [value1,Struct] = KeyValue2Struct(key,value,'key1');
% =================================================================================================================
Expand All @@ -34,4 +32,4 @@
end
end

end
end
16 changes: 0 additions & 16 deletions Infunctions/cell_del_empty.m

This file was deleted.

26 changes: 0 additions & 26 deletions Infunctions/char_to_logical.m

This file was deleted.

8 changes: 3 additions & 5 deletions Infunctions/del_quotation.m
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
function Str = del_quotation(str)
% =================================================================================================================
% discription:
% Delete the quotation of string
% =================================================================================================================
% parameter:
% Parameter:
% str: string || required: True || type: string || format: ''value''
% Str: string without quotation || required: True || type: string || format: 'value'
% =================================================================================================================
% example:
% Example:
% Str = del_quotation('''value''')
% =================================================================================================================

Expand All @@ -17,4 +15,4 @@
Str = str;
end

end
end
14 changes: 6 additions & 8 deletions Infunctions/split_path.m → Infunctions/del_separator.m
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
function varargout = split_path(varargin)
% =================================================================================================================
% discription:
function varargout = del_separator(varargin)
% Delete the last '/' from a path
% =================================================================================================================
% parameter:
% Parameter:
% varargin: path || required: True || type: char or string || format: '/home/xxx/xxx/'
% varargout: path without last '/' || required: True || type: char or string || format: '/home/xxx/xxx'
% =================================================================================================================
% example:
% path = split_path('/home/xxx/xxx/')
% [path1,path2] = split_path('/home/xxx/xxx', '/home/xxx/yyy/')
% Example:
% path = del_separator('/home/xxx/xxx/')
% [path1,path2] = del_separator('/home/xxx/xxx', '/home/xxx/yyy/')
% =================================================================================================================

varargout = cellfun(@zeros,cell(1:nargin),'UniformOutput',false);
Expand All @@ -25,4 +23,4 @@
end
end

end
end
Loading

0 comments on commit cb1e7b6

Please sign in to comment.