├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── bin ├── gtb_install_extlibs └── rename_dbd_files ├── config ├── .gitignore ├── configMainDT.txt ├── configMainRT.txt ├── configTemplate.txt ├── deploymentDT.txt └── deploymentRT.txt ├── documentation ├── Manual_v1.3.1.pdf ├── glider_data_processing_outline_delayed_time.png └── glider_data_processing_outline_real_time.pdf ├── ext_lib ├── .gitignore ├── bin │ └── .gitignore ├── lib │ └── .gitignore └── matlab │ └── .gitignore ├── glider_data ├── .gitignore ├── ascii │ └── .gitignore ├── binary │ └── .gitignore ├── figures │ └── .gitignore ├── log │ └── .gitignore └── netcdf │ └── .gitignore ├── jerico-ri-metadata.json ├── m ├── common_tools │ ├── @sftp │ │ ├── cd.m │ │ ├── close.m │ │ ├── delete.m │ │ ├── dir.m │ │ ├── disp.m │ │ ├── display.m │ │ ├── mget.m │ │ ├── mkdir.m │ │ ├── mput.m │ │ ├── private │ │ │ ├── mexsftp.c │ │ │ └── mexsftp.m │ │ ├── rename.m │ │ ├── rmdir.m │ │ └── sftp.m │ ├── getfiles.m │ ├── loadjson.m │ ├── loadnc.m │ ├── posixtime2utc.m │ ├── printfigure.m │ ├── readConfigFile.m │ ├── savejson.m │ ├── savenc.m │ ├── startLogging.m │ ├── strc.m │ ├── strfstruct.m │ └── utc2posixtime.m ├── configBasestations.m ├── configDTDeploymentInfoQueryDB.m ├── configDTFileOptionsSeaExplorer.m ├── configDTFileOptionsSeaglider.m ├── configDTFileOptionsSlocum.m ├── configDTOutputNetCDFL0SeaExplorer.m ├── configDTOutputNetCDFL0Seaglider.m ├── configDTOutputNetCDFL0Slocum.m ├── configDTOutputNetCDFL1.m ├── configDTOutputNetCDFL2.m ├── configDataGridding.m ├── configDataPreprocessingSeaExplorer.m ├── configDataPreprocessingSeaglider.m ├── configDataPreprocessingSlocum.m ├── configDataProcessingSeaExplorer.m ├── configDataProcessingSeaglider.m ├── configDataProcessingSlocumG1.m ├── configDataProcessingSlocumG2.m ├── configFigures.m ├── configGliderToolboxPath.m ├── configGliderToolboxVersion.m ├── configRTDeploymentInfoQueryDB.m ├── configRTFileOptionsSeaExplorer.m ├── configRTFileOptionsSeaglider.m ├── configRTFileOptionsSlocum.m ├── configRTOutputNetCDFL0SeaExplorer.m ├── configRTOutputNetCDFL0Seaglider.m ├── configRTOutputNetCDFL0Slocum.m ├── configRTOutputNetCDFL1.m ├── configRTOutputNetCDFL2.m ├── config_tools │ ├── Dictionary_EGONetCDFL1Parameters.m │ ├── Dictionary_SOCIBNetCDFL1Parameters.m │ ├── completeQCDictionary.m │ ├── completeUncertaintyDictionary.m │ ├── configDBAccess.m │ ├── configDTOutputNetCDFEGOL1.m │ ├── configDTOutputNetCDFEngSeaExplorer.m │ ├── configDTOutputNetCDFEngSeaglider.m │ ├── configDTOutputNetCDFEngSlocum.m │ ├── configDockservers.m │ ├── configPathsLocal.m │ ├── configPathsPublic.m │ ├── configRTOutputNetCDFEGOL1.m │ ├── configRTOutputNetCDFEngSeaExplorer.m │ ├── configRTOutputNetCDFEngSeaglider.m │ ├── configRTOutputNetCDFEngSlocum.m │ ├── configWRCPrograms.m │ ├── createFStruct.m │ ├── extractDeploymentConfig.m │ ├── listNetCDFL1Parameters.m │ └── setupConfiguration.m ├── database_tools │ └── getDeploymentInfoDB.m ├── dm_tools │ └── organizePublicData.m ├── gliderDataProcessing.m ├── main_glider_data_processing_dt.m ├── main_glider_data_processing_rt.m ├── mex_tools │ ├── poly2tri.c │ ├── poly2tri.m │ ├── posixtime.c │ └── posixtime.m ├── modules │ ├── module_ascii_to_l0.m │ ├── module_figures.m │ ├── module_figures.m~ │ ├── module_l0_to_EGOl1.m │ ├── module_l0_to_l1.m │ └── module_l1_to_l2.m ├── netcdf_tools │ ├── convert2NetCDFEGO.m │ ├── generateOutputNetCDF.m │ └── loadNetCDF.m ├── plotting_tools │ ├── generateGliderFigures.m │ ├── plotProfileStatistics.m │ ├── plotTSDiagram.m │ ├── plotTransectCurrentMap.m │ └── plotTransectVerticalSection.m ├── private │ └── test │ │ ├── ctd_pumped.dat │ │ ├── ctd_sharp_pumped.dat │ │ ├── ctd_sharp_unpumped.dat │ │ └── ctd_unpumped.dat ├── processing_tools │ ├── alignSGDiveParams.m │ ├── applySeabirdPressureFilter.m │ ├── bar2dbar.m │ ├── calibrateSBECT.m │ ├── calibrateWLECOBbFl2.m │ ├── cm2m.m │ ├── computeCTDFlowSpeed.m │ ├── computeCumulativeDistance.m │ ├── convertBinaryData.m │ ├── correctSensorLag.m │ ├── correctThermalLag.m │ ├── deploymentDataProcessing.m │ ├── deploymentDataProcessing.m~ │ ├── fillInvalidValues.m │ ├── fillSGMissingGPSDate.m │ ├── findProfiles.m │ ├── findSensorLagParams.m │ ├── findThermalLagParams.m │ ├── findTransects.m │ ├── getBinaryData.m │ ├── gridGliderData.m │ ├── nmea2deg.m │ ├── postProcessGliderData.m │ ├── preprocessGliderData.m │ ├── processGliderData.m │ ├── profileArea.m │ ├── seabirdFilter.m │ ├── sgcur2cart.m │ ├── sgdepth2pres.m │ ├── sxgoodfix.m │ └── validateProfile.m ├── qc_tools │ ├── postProcessQCGliderData.m │ └── processQCGliderData.m ├── reading_tools │ ├── dba2mat.m │ ├── dbacat.m │ ├── dbamerge.m │ ├── getBasestationFiles.m │ ├── getDockserverFiles.m │ ├── loadAsciiData.m │ ├── loadSeaExplorerData.m │ ├── loadSeagliderData.m │ ├── loadSlocumData.m │ ├── sgeng2mat.m │ ├── sgengcat.m │ ├── sglog2mat.m │ ├── sglogcat.m │ ├── sglogengmerge.m │ ├── sx2mat.m │ ├── sxcat.m │ ├── sxmerge.m │ └── xbd2dba.m ├── setupMexPoly2tri.m ├── setupMexPosixtime.m └── setupMexSFTP.m └── startup.m /.gitignore: -------------------------------------------------------------------------------- 1 | m/private/ 2 | m/mex_tools/*.mex* 3 | m/mex_tools/gpcl/ 4 | m/common_tools/@sftp/private/*.mex* 5 | m/common_tools/@sftp/private/libssh 6 | doc/ 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DOCDIR := doc 2 | #MFILES := $(wildcard m/*.m m/*_tools) 3 | MFILES := m 4 | IGNORE := private @sftp 5 | M := matlab 6 | 7 | ifeq ($(M), matlab) 8 | MFLAGS := -nodisplay -r 9 | else ifeq ($(M), octave) 10 | MFLAGS := --eval 11 | else 12 | $(error unknown interpreter '$(M)' (should be 'matlab' or 'octave')) 13 | endif 14 | 15 | all: doc 16 | 17 | doc: 18 | -mkdir -p doc 19 | rm -rf doc/* 20 | $(M) $(MFLAGS) \ 21 | "m2html('mfiles', {$(addprefix ',$(addsuffix ',$(MFILES)))}, \ 22 | 'ignore', {$(addprefix ',$(addsuffix ',$(IGNORE)))}, \ 23 | 'recursive', 'on', 'global', 'on', \ 24 | 'graph', 'on', 'search', 'on', 'download', 'on', \ 25 | 'template', 'frame', 'index', 'menu', 'htmldir', '$(DOCDIR)')" \ 26 | < /dev/null 27 | 28 | graph: 29 | echo "Generating graph from notes/graph.dot (be sure that it is up to date)." 30 | dot -Tsvg -o notes/graph.svg -T cmap -o notes/graph.map -Gsize="8,8" notes/graph.dot 31 | sed -i -n '1h;1!H;$${g;s#.*#\n#g;p;}' notes/graph.html 32 | sed -i '//r notes/graph.map' notes/graph.html 33 | 34 | .PHONY: all doc graph 35 | -------------------------------------------------------------------------------- /bin/rename_dbd_files: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/socib/glider_toolbox/2a438ba312d0497f1dfac96ede76af8af4bf4082/bin/rename_dbd_files -------------------------------------------------------------------------------- /config/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | configMainDT.txt 6 | configMainRT.txt 7 | configTemplate.txt 8 | deploymentDT.txt 9 | deploymentRT.txt 10 | 11 | -------------------------------------------------------------------------------- /config/configMainDT.txt: -------------------------------------------------------------------------------- 1 | ## 2 | # This file defines the configuration parameters for glider toolbox in delayed mode 3 | # processing by main_glider_data_processing_dt. Users can add any parameter 4 | # of the configuration to overwrite the default values. For detailed information 5 | # about the available parameters refer to the configTemplate.txt template. 6 | # Comments may be used by adding a # at the beginning of the line. 7 | # 8 | # Do not change the processing_mode value (equal to dt) of this configuration 9 | # since it is used mainly by the delayed mode processing script. 10 | # 11 | # Edit the data paths and the database information according to your needs. 12 | # 13 | ## 14 | 15 | 16 | ######################## 17 | # Processing mode 18 | 19 | processing_mode = dt 20 | 21 | ######################## 22 | # Paths to local and public data 23 | 24 | local_paths.base_dir = /path/to/local/folders 25 | 26 | public_paths.base_dir = /path/to/public/folders 27 | public_paths.base_url = http://your.public.url/path/to/data 28 | public_paths.base_html_dir = /your/public/url/path/to/data 29 | 30 | ######################### 31 | # Database 32 | 33 | db_access.active = 0 34 | db_access.server = jdbc:postgresql://mydb.myportal.mydomain:5433/my_data_base 35 | db_access.name = my_data_base 36 | db_access.user = db_user 37 | db_access.pass = top_secret 38 | db_access.driver = org.postgresql.Driver 39 | db_access.deployment_ids = id1|id2|id3... 40 | 41 | ######################### 42 | # Slocum file options 43 | 44 | file_options_slocum.format_conversion = 1 45 | -------------------------------------------------------------------------------- /config/configMainRT.txt: -------------------------------------------------------------------------------- 1 | ## 2 | # This file defines the configuration parameters for glider toolbox in delayed mode 3 | # processing by main_glider_data_processing_rt. Users can add any parameter 4 | # of the configuration to overwrite the default values. For detailed information 5 | # about the available parameters refer to the configTemplate.txt template. 6 | # Comments may be used by adding a # at the beginning of the line. 7 | # 8 | # Do not change the processing_mode value (equal to rt) of this configuration 9 | # since it is used mainly by the real time mode processing script. 10 | # 11 | # Edit the data paths, the dockserver and the database information according to your needs. 12 | # 13 | ## 14 | 15 | 16 | ######################## 17 | # Processing mode 18 | 19 | processing_mode = rt 20 | 21 | ######################## 22 | # Paths to local and public data 23 | 24 | local_paths.base_dir = /path/to/local/folders 25 | 26 | public_paths.base_dir = /path/to/public/folders 27 | public_paths.base_url = http://your.public.url/path/to/data 28 | public_paths.base_html_dir = /your/public/url/path/to/data 29 | 30 | ######################### 31 | # Database 32 | 33 | db_access.active = 0 34 | db_access.server = jdbc:postgresql://mydb.myportal.mydomain:5433/my_data_base 35 | db_access.name = my_data_base 36 | db_access.user = db_user 37 | db_access.pass = top_secret 38 | db_access.driver = org.postgresql.Driver 39 | 40 | ######################### 41 | # Dockserver 42 | 43 | dockservers.active = 1 44 | dockservers.remote_base_dir = /var/opt/gmc/gliders 45 | dockservers.remote_xbd_dir = from-glider 46 | dockservers.remote_log_dir = logs 47 | dockservers.server(1).url = http://mydockserver01.myportal.mydomain 48 | dockservers.server(1).host = xxx.xxx.xxx.xxx 49 | dockservers.server(1).user = dock_user 50 | dockservers.server(1).pass = top_secret 51 | -------------------------------------------------------------------------------- /config/deploymentDT.txt: -------------------------------------------------------------------------------- 1 | ## 2 | # This file defines the deployments to be processed by the glider toolbox 3 | # when no database is available in delayed mode. 4 | # 5 | # When db_access.active is set to 0 in configMainDT.txt, the main_glider_data_processing_dt 6 | # script will read this file and create a list of deployments to be processed 7 | # from the content of its content 8 | # 9 | ## 10 | 11 | # Required parameters 12 | deployment_list(1).deployment_id = 773 13 | deployment_list(1).deployment_name = your_deployment_name 14 | deployment_list(1).deployment_start = 7.3700e+05 15 | deployment_list(1).deployment_end = NaN 16 | deployment_list(1).glider_name = your_glider_name 17 | deployment_list(1).glider_serial = 518 18 | deployment_list(1).glider_model = Slocum G2 Deep 19 | deployment_list(1).glider_instrument_name = SCB-SGDEEP003 20 | deployment_list(1).glider_deployment_code = 0002 21 | 22 | # Optional parameters 23 | deployment_list(1).project = MARS2015 24 | deployment_list(1).abstract = Some description 25 | deployment_list(1).project_url = http://myproject.org/ 26 | deployment_list(1).principal_investigator = Pi Name 27 | deployment_list(1).principal_investigator_email = pi@glider.edu 28 | deployment_list(1).author = Glider Respo 29 | deployment_list(1).author_email = respo@glider.edu 30 | deployment_list(1).institution = IEO-PLOCAN 31 | deployment_list(1).instrument = 32 | deployment_list(1).instrument_manufacturer = 33 | deployment_list(1).instrument_model = 34 | 35 | # Add as many deployments as needed as follow for deployment i 36 | # deployment_list(i).deployment_id = 773 37 | # deployment_list(i).deployment_name = your_deployment_name 38 | # deployment_list(i).deployment_start = 7.3700e+05 39 | # deployment_list(i).deployment_end = NaN 40 | # deployment_list(i).glider_name = your_glider_name 41 | # deployment_list(i).glider_serial = 518 42 | # deployment_list(i).glider_model = Slocum G2 Deep -------------------------------------------------------------------------------- /config/deploymentRT.txt: -------------------------------------------------------------------------------- 1 | ## 2 | # This file defines the deployments to be processed by the glider toolbox 3 | # when no database is available in real time. 4 | # 5 | # When db_access.active is set to 0 in configMainRT.txt, the main_glider_data_processing_rt 6 | # script will read this file and create a list of deployments to be processed 7 | # from the content of its content 8 | # 9 | ## 10 | 11 | 12 | # Required parameters 13 | deployment_list(1).deployment_id = 773 14 | deployment_list(1).deployment_name = your_deployment_name 15 | deployment_list(1).deployment_start = 7.3700e+05 16 | deployment_list(1).deployment_end = NaN 17 | deployment_list(1).glider_name = your_glider_name 18 | deployment_list(1).glider_serial = 518 19 | deployment_list(1).glider_model = Slocum G2 Deep 20 | deployment_list(1).glider_instrument_name = SCB-SGDEEP003 21 | deployment_list(1).glider_deployment_code = 0002 22 | 23 | # Examples of optional parameters 24 | deployment_list(1).project = MARS2015 25 | deployment_list(1).abstract = Some description 26 | deployment_list(1).project_url = http://myproject.org/ 27 | deployment_list(1).principal_investigator = Pi Name 28 | deployment_list(1).principal_investigator_email = pi@glider.edu 29 | deployment_list(1).author = Glider Respo 30 | deployment_list(1).author_email = respo@glider.edu 31 | deployment_list(1).glider_instrument_name = SCB-SGDEEP003 32 | deployment_list(1).institution = IEO-PLOCAN 33 | deployment_list(1).instrument = 34 | deployment_list(1).instrument_manufacturer = 35 | deployment_list(1).instrument_model = 36 | 37 | 38 | # Add as many deployments as needed as follow for deployment i 39 | # deployment_list(i).deployment_id = 773 40 | # deployment_list(i).deployment_name = your_deployment_name 41 | # deployment_list(i).deployment_start = 7.3700e+05 42 | # deployment_list(i).deployment_end = NaN 43 | # deployment_list(i).glider_name = your_glider_name 44 | # deployment_list(i).glider_serial = 518 45 | # deployment_list(i).glider_model = Slocum G2 Deep -------------------------------------------------------------------------------- /documentation/Manual_v1.3.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/socib/glider_toolbox/2a438ba312d0497f1dfac96ede76af8af4bf4082/documentation/Manual_v1.3.1.pdf -------------------------------------------------------------------------------- /documentation/glider_data_processing_outline_delayed_time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/socib/glider_toolbox/2a438ba312d0497f1dfac96ede76af8af4bf4082/documentation/glider_data_processing_outline_delayed_time.png -------------------------------------------------------------------------------- /documentation/glider_data_processing_outline_real_time.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/socib/glider_toolbox/2a438ba312d0497f1dfac96ede76af8af4bf4082/documentation/glider_data_processing_outline_real_time.pdf -------------------------------------------------------------------------------- /ext_lib/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /ext_lib/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /ext_lib/lib/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /ext_lib/matlab/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /glider_data/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /glider_data/ascii/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /glider_data/binary/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /glider_data/figures/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /glider_data/log/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /glider_data/netcdf/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /jerico-ri-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "_class": "Software", 3 | "alias": "https://github.com/socib/glider_toolbox", 4 | "abstract": "MATLAB/Octave scripts to manage data collected by a glider fleet, including data download, data processing and product and figure generation, both in real time and delayed time.", 5 | "author": { 6 | "_class": "Organization", 7 | "alias": "https://edmo.seadatanet.org/report/3410" 8 | }, 9 | "created": "2011-03-03", 10 | "contributor": [ 11 | { 12 | "_class": "Person", 13 | "name": "Joan Pau Beltran " 14 | }, 15 | { 16 | "_class": "Person", 17 | "name": "Tomeu Garau " 18 | }, 19 | { 20 | "_class": "Person", 21 | "name": "Grant Rogers " 22 | }, 23 | { 24 | "_class": "Person", 25 | "name": "Andreas Krietemeyer" 26 | }, 27 | { 28 | "_class": "Person", 29 | "name": "Frederic Cyr" 30 | }, 31 | { 32 | "_class": "Person", 33 | "name": "Juan Gabriel Fernandez " 34 | } 35 | ], 36 | "description": "The glider toolbox is a set of MATLAB/Octave scripts and functions developed at SOCIB to manage the data collected by a glider fleet. They cover the main stages of the data management process both in real time and delayed time mode: metadata aggregation, data download, data processing, and generation of data products and figures.", 37 | "distribution": { 38 | "_class": "Distribution", 39 | "accessURL": "https://github.com/socib/glider_toolbox" 40 | }, 41 | "downloadURL": "https://github.com/socib/glider_toolbox/archive/refs/heads/master.zip", 42 | "keywords": ["matlab","netcdf","octave","physical-oceanography","ocean-sciences","seaglider","data-preservation","glider-toolbox","slocum","seaexplorer","socib"], 43 | "language": ["English"], 44 | "license": "Copyright (C) 2013-2018 ICTS SOCIB - Servei d'observació i predicció costaner de les Illes Balears http://www.socib.es\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.", 45 | "modified": "2017-07-31", 46 | "name": "SOCIB glider toolbox", 47 | "organization": { 48 | "_class": "Organization", 49 | "alias": "https://edmo.seadatanet.org/report/3410" 50 | }, 51 | "owner": { 52 | "_class": "Organization", 53 | "alias": "https://edmo.seadatanet.org/report/3410" 54 | }, 55 | "publisher": { 56 | "_class": "Organization", 57 | "alias": "https://edmo.seadatanet.org/report/3410" 58 | }, 59 | "published": "2014-08-07", 60 | "programming_language": ["MATLAB", "M", "C", "Other"], 61 | "url": "https://github.com/socib/glider_toolbox", 62 | "version": "v1.2.0" 63 | } -------------------------------------------------------------------------------- /m/common_tools/@sftp/cd.m: -------------------------------------------------------------------------------- 1 | function pwd = cd(h, path) 2 | %CD Change or get current working directory on an SFTP server. 3 | % 4 | % Syntax: 5 | % CD(H, PATH) 6 | % PWD = CD(H, PATH) 7 | % PWD = CD(H) 8 | % 9 | % Description: 10 | % CD(H, PATH) changes the current working directory to the one specified. 11 | % 12 | % PWD = CD(H, PATH) changes the working directory and returns the new one. 13 | % 14 | % PWD = CD(H) returns the current working directory. 15 | % 16 | % Examples: 17 | % % Get current directory: 18 | % old_dir = cd(h) 19 | % % Move up one directory and get new current directory: 20 | % new_dir = cd(h, '..'): 21 | % % Go back to previous directory: 22 | % cd(old_dir) 23 | % 24 | % See also: 25 | % SFTP 26 | % 27 | % Authors: 28 | % Joan Pau Beltran 29 | 30 | % Copyright (C) 2014-2016 31 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 32 | % 33 | % 34 | % This program is free software: you can redistribute it and/or modify 35 | % it under the terms of the GNU General Public License as published by 36 | % the Free Software Foundation, either version 3 of the License, or 37 | % (at your option) any later version. 38 | % 39 | % This program is distributed in the hope that it will be useful, 40 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 41 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 42 | % GNU General Public License for more details. 43 | % 44 | % You should have received a copy of the GNU General Public License 45 | % along with this program. If not, see . 46 | 47 | if (nargin > 1) 48 | mexsftp('cwd', h.sftp_handle, path); 49 | end 50 | pwd = mexsftp('pwd', h.sftp_handle); 51 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/close.m: -------------------------------------------------------------------------------- 1 | function close(h) 2 | %CLOSE Close a connection with an SFTP server. 3 | % 4 | % Syntax: 5 | % CLOSE(H) 6 | % 7 | % Description: 8 | % CLOSE(H) closes the connection with the server. 9 | % 10 | % Examples: 11 | % close(h) 12 | % 13 | % See also: 14 | % SFTP 15 | % 16 | % Authors: 17 | % Joan Pau Beltran 18 | 19 | % Copyright (C) 2014-2016 20 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 21 | % 22 | % 23 | % This program is free software: you can redistribute it and/or modify 24 | % it under the terms of the GNU General Public License as published by 25 | % the Free Software Foundation, either version 3 of the License, or 26 | % (at your option) any later version. 27 | % 28 | % This program is distributed in the hope that it will be useful, 29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 | % GNU General Public License for more details. 32 | % 33 | % You should have received a copy of the GNU General Public License 34 | % along with this program. If not, see . 35 | 36 | mexsftp('disconnect', h.sftp_handle); 37 | 38 | end 39 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/delete.m: -------------------------------------------------------------------------------- 1 | function delete(h, filename) 2 | %DELETE Delete file(s) on an SFTP server. 3 | % 4 | % Syntax: 5 | % DELETE(H, FILENAME) 6 | % 7 | % Description: 8 | % DELETE(H, FILENAME) deletes file(s) on the server. 9 | % 10 | % Examples: 11 | % delete(h, filename) 12 | % 13 | % See also: 14 | % SFTP 15 | % 16 | % Authors: 17 | % Joan Pau Beltran 18 | 19 | % Copyright (C) 2014-2016 20 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 21 | % 22 | % 23 | % This program is free software: you can redistribute it and/or modify 24 | % it under the terms of the GNU General Public License as published by 25 | % the Free Software Foundation, either version 3 of the License, or 26 | % (at your option) any later version. 27 | % 28 | % This program is distributed in the hope that it will be useful, 29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 | % GNU General Public License for more details. 32 | % 33 | % You should have received a copy of the GNU General Public License 34 | % along with this program. If not, see . 35 | 36 | try 37 | atts = mexsftp('lsfile', h.sftp_handle, filename); 38 | catch exception 39 | if ~strcmp(exception.identifier, 'sftp:lsfile:ListError') 40 | rethrow(exception); 41 | end 42 | atts = mexsftp('lsglob', h.sftp_handle, filename); 43 | end 44 | 45 | filesep_index = find(filename == '/', 1, 'last'); 46 | if isempty(filesep_index) 47 | prefix = ''; 48 | else 49 | prefix = [filename(1:filesep_index-1) '/']; 50 | end 51 | 52 | for i = 1:numel(atts) 53 | mexsftp('delfile', h.sftp_handle, [prefix atts(i).name]); 54 | end 55 | 56 | end 57 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/dir.m: -------------------------------------------------------------------------------- 1 | function list = dir(h, path) 2 | %DIR List files on an SFTP server. 3 | % 4 | % Syntax: 5 | % DIR(H) 6 | % DIR(H, PATH) 7 | % LIST = DIR(H, ...) 8 | % 9 | % Description: 10 | % DIR(H, PATH) lists the files in a path. 11 | % If the path is a directory, the files in the directory are listed. 12 | % If the path is a file, tha file itself is listed. 13 | % Otherwise, the path is considered a glob which may contain wildcards 14 | % ('?' or '*'), and only files matching the glob are listed, if any. 15 | % 16 | % LIST = DIR(H, ...) returns the files in an M-by-1 structure with fields: 17 | % NAME: file name 18 | % BYTES: number of bytes allocated to the file 19 | % ISDIR: whether file is a directory or not 20 | % DATE: modification time timestamp (string) 21 | % DATENUM: modification time as a serial date number 22 | % 23 | % Examples: 24 | % % Print contents of current directory: 25 | % dir(h) 26 | % % Print contents of parent directory: 27 | % dir(h, '..') 28 | % % Get attributes of files in current directory: 29 | % list = d(h) 30 | % % Get attributes of files in parent directory: 31 | % list = d(h, '..') 32 | % 33 | % See also: 34 | % SFTP 35 | % 36 | % Authors: 37 | % Joan Pau Beltran 38 | 39 | % Copyright (C) 2014-2016 40 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 41 | % 42 | % 43 | % This program is free software: you can redistribute it and/or modify 44 | % it under the terms of the GNU General Public License as published by 45 | % the Free Software Foundation, either version 3 of the License, or 46 | % (at your option) any later version. 47 | % 48 | % This program is distributed in the hope that it will be useful, 49 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 50 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 51 | % GNU General Public License for more details. 52 | % 53 | % You should have received a copy of the GNU General Public License 54 | % along with this program. If not, see . 55 | 56 | if (nargin < 2) 57 | path = '.'; 58 | end 59 | 60 | try 61 | atts = mexsftp('lsfile', h.sftp_handle, path); 62 | catch exception 63 | if ~strcmp(exception.identifier, 'sftp:lsfile:ListError') 64 | rethrow(exception); 65 | end 66 | atts = []; 67 | end 68 | if isempty(atts) 69 | atts = mexsftp('lsglob', h.sftp_handle, path); 70 | elseif atts.isdir 71 | atts = mexsftp('lsdir', h.sftp_handle, path); 72 | end 73 | 74 | for i = 1:numel(atts) 75 | atts(i).datenum = datenum(atts(i).date); 76 | atts(i).date = datestr(atts(i).date, 'local'); 77 | end 78 | 79 | if nargout < 1 80 | % Display in columns. 81 | disp(' '); 82 | if ~isempty(atts) 83 | entries = sortrows(char(strcat({atts.name}, {' '}))); 84 | width = [1 0] * get(0, 'CommandWindowSize')'; 85 | cols = max(1, floor(width / size(entries, 2))); 86 | rows = ceil(size(entries, 1)/cols); 87 | entries(end+1:rows*cols, :) = ' '; 88 | disp(reshape(entries(reshape(1:rows*cols, rows, [])',:)', [], rows)') 89 | end 90 | disp(' '); 91 | else 92 | list = atts; 93 | end 94 | 95 | end 96 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/disp.m: -------------------------------------------------------------------------------- 1 | function disp(h) 2 | % DISP Display method for the SFTP object. 3 | % 4 | % Syntax: 5 | % DISP(H) 6 | % 7 | % Description: 8 | % DISP(H) displays an SFTP object as text. 9 | % 10 | % Examples: 11 | % disp(h) 12 | % 13 | % See also: 14 | % SFTP 15 | % 16 | % Authors: 17 | % Joan Pau Beltran 18 | 19 | if length(h) ~= 1 20 | % FTP array; Should work for empty case as well. 21 | s = size(h); 22 | str = sprintf('%dx',s); 23 | str(end) = []; 24 | fprintf('%s array of SFTP objects\n', str); 25 | else 26 | disp(sprintf( ... 27 | ' SFTP Object\n host: %s\n port: %s\n user: %s\n dir: %s\n', ... 28 | h.host, num2str(h.port), h.username, mexsftp('pwd', h.sftp_handle))); 29 | end 30 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/display.m: -------------------------------------------------------------------------------- 1 | function display(h) 2 | % DISPLAY Display method for the SFTP object. 3 | % 4 | % Syntax: 5 | % DISPLAY(H) 6 | % 7 | % Description: 8 | % DISPLAY(H) displays an SFTP object as text. 9 | % 10 | % Examples: 11 | % display(h) 12 | % 13 | % See also: 14 | % SFTP 15 | % 16 | % Authors: 17 | % Joan Pau Beltran 18 | 19 | fprintf('\n%s = \n\n', inputname(1)); 20 | disp(h) 21 | fprintf('\n'); 22 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/mget.m: -------------------------------------------------------------------------------- 1 | function list = mget(h, path, target) 2 | %MGET Download file(s) from an SFTP server. 3 | % 4 | % Syntax: 5 | % MGET(H, PATH) 6 | % MGET(H, PATH, TARGET) 7 | % LIST = MGET(H, ...) 8 | % 9 | % Description: 10 | % MGET(H, PATH) downloads file(s) from the server to the current directory. 11 | % If the path is a directory, the directory and its contents are downloaded. 12 | % If the path is a file, tha file itself is downloaded. 13 | % Otherwise, the path is considered a glob which may contain wildcards 14 | % ('?' or '*'), and only files matching the glob are downloaded, if any. 15 | % 16 | % MGET(H, PATH, TARGET) downloads the file(s) to the given target directory 17 | % instead of the current one. 18 | % 19 | % LIST = MGET(H, ...) returns the list of downloaded files. 20 | % 21 | % Examples: 22 | % % Download file from remote working directory to current working directory: 23 | % mget(h, filename) 24 | % % Download file from remote working directory to another directory: 25 | % mget(h, filename, target) 26 | % % Download all files and directories in remote working directory: 27 | % mget(h, '*') 28 | % % Download all hidden files and directories in remote working directory, 29 | % % to a different directory: 30 | % list = mget(h, '.*', stash) 31 | % 32 | % See also: 33 | % SFTP 34 | % 35 | % Authors: 36 | % Joan Pau Beltran 37 | 38 | % Copyright (C) 2014-2016 39 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 40 | % 41 | % 42 | % This program is free software: you can redistribute it and/or modify 43 | % it under the terms of the GNU General Public License as published by 44 | % the Free Software Foundation, either version 3 of the License, or 45 | % (at your option) any later version. 46 | % 47 | % This program is distributed in the hope that it will be useful, 48 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 49 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 50 | % GNU General Public License for more details. 51 | % 52 | % You should have received a copy of the GNU General Public License 53 | % along with this program. If not, see . 54 | 55 | if (nargin < 3) 56 | target = pwd(); 57 | end 58 | 59 | try 60 | atts = mexsftp('lsfile', h.sftp_handle, path); 61 | catch exception 62 | if ~strcmp(exception.identifier, 'sftp:lsfile:ListError') 63 | rethrow(exception); 64 | end 65 | atts = mexsftp('lsglob', h.sftp_handle, path); 66 | end 67 | if isempty(atts) 68 | error('sftp:mget:NotFound', ... 69 | 'No such file or directory: %s.', path); 70 | end 71 | 72 | filesep_index = find(path == '/', 1, 'last'); 73 | if isempty(filesep_index) 74 | rprefix = ''; 75 | lprefix = target; 76 | else 77 | rprefix = path(1:filesep_index); 78 | lprefix = fullfile(target, strrep(rprefix, '/', filesep())); 79 | end 80 | [status, attrout] = fileattrib(lprefix); 81 | if ~status 82 | [success, message] = mkdir(lprefix); 83 | if ~success 84 | error('sftp:mget:DirectoryError', ... 85 | 'Could not create directory %s: %s.', lprefix, message); 86 | end 87 | elseif ~attrout.directory 88 | error('sftp:mget:DirectoryError', 'Not a directory: %s.', lprefix); 89 | end 90 | 91 | dflags = [atts.isdir]'; 92 | rpaths = strcat(rprefix, {atts.name}'); 93 | list = cell(0,1); 94 | while ~isempty(rpaths) 95 | rpath = rpaths{end}; 96 | dflag = dflags(end); 97 | lpath = fullfile(target, strrep(rpath, '/', filesep())); 98 | rpaths(end) = []; 99 | dflags(end) = []; 100 | if dflag 101 | [status, attrout] = fileattrib(lpath); 102 | if ~status 103 | [success, message] = mkdir(lpath); 104 | if ~success 105 | error('sftp:mget:DirectoryError', ... 106 | 'Could not create directory %s: %s.', lpath, message); 107 | end 108 | elseif ~attrout.directory 109 | error('sftp:mget:DirectoryError', 'Not a directory: %s.', attrout.Name); 110 | end 111 | atts = mexsftp('lsdir', h.sftp_handle, rpath); 112 | if ~isempty(atts) 113 | dflags(end + (1:numel(atts))) = [atts.isdir]'; 114 | rpaths(end + (1:numel(atts))) = strcat(rpath, '/', {atts.name}'); 115 | end 116 | else 117 | mexsftp('getfile', h.sftp_handle, rpath, lpath); 118 | end 119 | list{end+1, 1} = lpath; 120 | end 121 | 122 | end 123 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/mkdir.m: -------------------------------------------------------------------------------- 1 | function mkdir(h, dirname) 2 | %MKDIR Create a new directory on an SFTP server. 3 | % 4 | % Syntax: 5 | % MKDIR(H, DIRNAME) 6 | % 7 | % Description: 8 | % MKDIR(H, DIRNAME) creates a directory on the server. 9 | % 10 | % Examples: 11 | % mkdir(h, dirname) 12 | % 13 | % See also: 14 | % SFTP 15 | % 16 | % Authors: 17 | % Joan Pau Beltran 18 | 19 | % Copyright (C) 2014-2016 20 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 21 | % 22 | % 23 | % This program is free software: you can redistribute it and/or modify 24 | % it under the terms of the GNU General Public License as published by 25 | % the Free Software Foundation, either version 3 of the License, or 26 | % (at your option) any later version. 27 | % 28 | % This program is distributed in the hope that it will be useful, 29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 | % GNU General Public License for more details. 32 | % 33 | % You should have received a copy of the GNU General Public License 34 | % along with this program. If not, see . 35 | 36 | mexsftp('mkdir', h.sftp_handle, dirname); 37 | 38 | end 39 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/mput.m: -------------------------------------------------------------------------------- 1 | function list = mput(h, path) 2 | %MPUT Upload file(s) to an SFTP server. 3 | % 4 | % Syntax: 5 | % MPUT(H, PATH) 6 | % LIST = MPUT(H, PATH) 7 | % 8 | % Description: 9 | % MPUT(H, PATH) uploads file(s) to the server. 10 | % If the path is a directory, the directory and its contents are uploaded. 11 | % If the path is a file, the file itself is uploaded. 12 | % Otherwise, the path is considered a glob which may contain wildcards 13 | % ('*'), and only files matching the glob are uploaded, if any. 14 | % 15 | % LIST = MPUT(H, ...) returns the list of uploaded files. 16 | % 17 | % Examples: 18 | % % Upload file to remote working directory: 19 | % mput(h, filename) 20 | % % Upload all files and directories in current working directory: 21 | % mput(h, '*') 22 | % % Upoad all hidden files and directories to remote working directory. 23 | % list = mput(h, '.*') 24 | % 25 | % See also: 26 | % SFTP 27 | % 28 | % Authors: 29 | % Joan Pau Beltran 30 | 31 | % Copyright (C) 2014-2016 32 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 33 | % 34 | % 35 | % This program is free software: you can redistribute it and/or modify 36 | % it under the terms of the GNU General Public License as published by 37 | % the Free Software Foundation, either version 3 of the License, or 38 | % (at your option) any later version. 39 | % 40 | % This program is distributed in the hope that it will be useful, 41 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | % GNU General Public License for more details. 44 | % 45 | % You should have received a copy of the GNU General Public License 46 | % along with this program. If not, see . 47 | 48 | [status, attrout] = fileattrib(path); 49 | if ~status 50 | error('sftp:mget:FileError', attrout); 51 | end 52 | % FILEATTRIB recurses down directories when passed a glob, use DIR instead. 53 | if isscalar(attrout) 54 | [source, name, ext] = fileparts(attrout.Name); 55 | atts = struct(); 56 | atts.name = [name ext]; 57 | atts.isdir = attrout.directory; 58 | else 59 | [source, name, ext] = fileparts(path); 60 | if isempty(source) 61 | source = pwd(); 62 | end 63 | atts = dir(path); 64 | atts = atts(~(strcmp({atts.name}, '.') | strcmp({atts.name}, '..'))); 65 | end 66 | 67 | target = mexsftp('pwd', h.sftp_handle); 68 | if target(end) ~= '/' 69 | target = [target '/']; 70 | end 71 | dflags = [atts.isdir]'; 72 | rpaths = {atts.name}'; 73 | list = cell(0,1); 74 | while ~isempty(rpaths) 75 | rpath = rpaths{end}; 76 | dflag = dflags(end); 77 | lpath = strrep(rpath, '/', filesep()); 78 | rpaths(end) = []; 79 | dflags(end) = []; 80 | if dflag 81 | mkdir(h, rpath); 82 | atts = dir(fullfile(source, lpath)); 83 | atts = atts(~(strcmp({atts.name}, '.') | strcmp({atts.name}, '..'))); 84 | if ~isempty(atts) 85 | dflags(end + (1:numel(atts))) = [atts.isdir]'; 86 | rpaths(end + (1:numel(atts))) = strcat(rpath, '/', {atts.name}'); 87 | end 88 | else 89 | mexsftp('putfile', h.sftp_handle, ... 90 | fullfile(source, lpath), strcat(target, rpath)); 91 | end 92 | list{end+1, 1} = strcat(target, rpath); 93 | end 94 | 95 | end 96 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/private/mexsftp.m: -------------------------------------------------------------------------------- 1 | function varargout = mexsftp(funcname, varargin) 2 | %MEXSFTP Mex interface to libssh for sftp connections. 3 | % 4 | % Syntax: 5 | % H = MEXSFTP('create', HOST, PORT, USER, PASS) 6 | % MEXSFTP('delete', S) 7 | % MEXSFTP('connect', H, HOST, PORT, USER, PASS) 8 | % MEXSFTP('disconnect', H) 9 | % PATH = MEXSFTP('pwd', H) 10 | % MEXSFTP('cwd', H, PATH) 11 | % ATTS = MEXSFTP('lsfile', H, FILE) 12 | % ATTS = MEXSFTP('lsdir', H, DIRECTORY) 13 | % ATTS = MEXSFTP('lsglob', H, GLOB) 14 | % MEXSFTP('mkdir', H, PATH) 15 | % MEXSFTP('rmdir', H, PATH) 16 | % MEXSFTP('rename', H, SOURCE, TARGET) 17 | % MEXSFTP('delfile', H, PATH) 18 | % MEXSFTP('getfile', H, RPATH, LPATH) 19 | % MEXSFTP('putfile', H, LPATH, RPATH) 20 | % 21 | % Description: 22 | % H = MEXSFTP('create', H, HOST, PORT, USER, PASS) creates a connection 23 | % to the server, initializing the ssh and sftp sessions and the working 24 | % directory, and returns a reference to the sftp connection. 25 | % If no port, user or password are given, the default values are used. 26 | % 27 | % MEXSFTP('delete', H) closes a connection to the server, and deletes the 28 | % referenced sftp connection, destroying the ssh and sftp sessions. 29 | % 30 | % MEXSFTP('connect', H, HOST, PORT, USER, PASS) opens a connection to the 31 | % server using the internal reference to the already created sftp connection. 32 | % If no port, user or password are given, the default values are used. 33 | % 34 | % MEXSFTP('disconnect', H) closes a connection to the server, but does not 35 | % delete the referenced sftp connection. 36 | % 37 | % PATH = MEXSFTP('pwd', H) returns the current working directory on the 38 | % server. 39 | % 40 | % MEXSFTP('cwd', H, PATH) changes the current working directory on the 41 | % server. 42 | % 43 | % ATTS = MEXSFTP('lsfile', H, FILE) returns the attributes of a file on the 44 | % server in a scalar struct with the following fields: 45 | % NAME: string with the file name (without leading directory path). 46 | % BYTES: double with the file size in bytes. 47 | % ISDIR: logical whether the file is a directory. 48 | % DATE: array with the modification time as a date vector. 49 | % 50 | % ATTS = MEXSFTP('lsdir', H, DIRECTORY) returns the attributes of all 51 | % entries in a directory on the server in a struct array with the fields 52 | % described above. 53 | % 54 | % ATTS = MEXSFTP('lsglob', H, GLOB) returns the attributes of all files on 55 | % the server whose name matches a glob in a struct array with the fields 56 | % described above. Wildcards are only allowed in the file name, not in the 57 | % leading directory path. If no file matches the glob, the result is empty. 58 | % 59 | % MEXSFTP('mkdir', H, PATH) creates a new directory on the server. 60 | % Parent directories should exist. 61 | % 62 | % MEXSFTP('rmdir', H, PATH) deletes a directory from the server. 63 | % Directory should be empty. 64 | % 65 | % MEXSFTP('rename', H, SOURCE, TARGET) renames or moves a file on the server. 66 | % Parent directories of new path should exist. 67 | % 68 | % MEXSFTP('delfile', H, PATH) deletes a file on the server. 69 | % File can not be a directory, use 'rmdir' instead. 70 | % 71 | % MEXSFTP('getfile', H, RPATH, LPATH) downloads the file from the remote path 72 | % on the server to the local path. Local path is the full name of the target, 73 | % and leading directories should exist. Remote path must not be a directory. 74 | % 75 | % MEXSFTP('putfile', H, LPATH, RPATH) uploads a file from the local path to 76 | % the remote path on the server. Remote path is the full name of the target 77 | % and leading directories should exist. Local path must not be a directory. 78 | % 79 | % Notes: 80 | % This function provides an interface to perform operations through an SFTP 81 | % connection to a remote server using the API provided by the library libssh. 82 | % All low level operations are implemented in the companion mex file. 83 | % 84 | % This function is not intended to be called directly by the user, 85 | % but to implement methods of the SFTP objects. Use methods of SFTP instead. 86 | % 87 | % References: 88 | % Aris Adamantiadis and Andreas Schneider, libssh library: 89 | % 90 | % 91 | % See also: 92 | % SFTP 93 | % 94 | % Authors: 95 | % Joan Pau Beltran 96 | 97 | % Copyright (C) 2014-2016 98 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 99 | % 100 | % 101 | % This program is free software: you can redistribute it and/or modify 102 | % it under the terms of the GNU General Public License as published by 103 | % the Free Software Foundation, either version 3 of the License, or 104 | % (at your option) any later version. 105 | % 106 | % This program is distributed in the hope that it will be useful, 107 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 108 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 109 | % GNU General Public License for more details. 110 | % 111 | % You should have received a copy of the GNU General Public License 112 | % along with this program. If not, see . 113 | 114 | error('sftp:mexsftp:MissingMexFile', 'Missing required mex file'); 115 | 116 | end 117 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/rename.m: -------------------------------------------------------------------------------- 1 | function rename(h, oldname, newname) 2 | %RENAME Rename a file or directory on an SFTP server. 3 | % 4 | % Syntax: 5 | % RENAME(H, OLDNAME, NEWNAME) 6 | % 7 | % Description: 8 | % RENAME(H, OLDNAME, NEWNAME) renames or moves a file on the server. 9 | % 10 | % Examples: 11 | % rename(h, oldname, newname) 12 | % 13 | % See also: 14 | % SFTP 15 | % 16 | % Authors: 17 | % Joan Pau Beltran 18 | 19 | % Copyright (C) 2014-2016 20 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 21 | % 22 | % 23 | % This program is free software: you can redistribute it and/or modify 24 | % it under the terms of the GNU General Public License as published by 25 | % the Free Software Foundation, either version 3 of the License, or 26 | % (at your option) any later version. 27 | % 28 | % This program is distributed in the hope that it will be useful, 29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 | % GNU General Public License for more details. 32 | % 33 | % You should have received a copy of the GNU General Public License 34 | % along with this program. If not, see . 35 | 36 | mexsftp('rename', h.sftp_handle, oldname, newname); 37 | 38 | end 39 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/rmdir.m: -------------------------------------------------------------------------------- 1 | function rmdir(h, dirname) 2 | %RMDIR Remove a directory on an SFTP server. 3 | % 4 | % Syntax: 5 | % RMDIR(H, DIRNAME) 6 | % 7 | % Description: 8 | % RMDIR(H, DIRNAME) removes a directory on the server. 9 | % 10 | % Examples: 11 | % rmdir(h, dirname) 12 | % 13 | % See also: 14 | % SFTP 15 | % 16 | % Authors: 17 | % Joan Pau Beltran 18 | 19 | % Copyright (C) 2014-2016 20 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 21 | % 22 | % 23 | % This program is free software: you can redistribute it and/or modify 24 | % it under the terms of the GNU General Public License as published by 25 | % the Free Software Foundation, either version 3 of the License, or 26 | % (at your option) any later version. 27 | % 28 | % This program is distributed in the hope that it will be useful, 29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 | % GNU General Public License for more details. 32 | % 33 | % You should have received a copy of the GNU General Public License 34 | % along with this program. If not, see . 35 | 36 | mexsftp('rmdir', h.sftp_handle, dirname); 37 | 38 | end 39 | -------------------------------------------------------------------------------- /m/common_tools/@sftp/sftp.m: -------------------------------------------------------------------------------- 1 | function h = sftp(host, username, password) 2 | %SFTP Create an SFTP object. 3 | % 4 | % Syntax: 5 | % H = SFTP(HOST) 6 | % H = SFTP(HOST, USERNAME) 7 | % H = SFTP(HOST, USERNAME, PASSWORD) 8 | % 9 | % Description: 10 | % H = SFTP(HOST, USERNAME, PASSWORD) returns an SFTP object. 11 | % If USERNAME is not specified, the default user for that host will be used. 12 | % If PASSWORD is not specified, public key authentication will be used. 13 | % 14 | % Examples: 15 | % h = sftp(host) 16 | % h = sftp(host, username) 17 | % h = sftp(host, username, password) 18 | % 19 | % See also: 20 | % CLOSE 21 | % CD 22 | % DIR 23 | % MGET 24 | % MPUT 25 | % RENAME 26 | % DELETE 27 | % MKDIR 28 | % RMDIR 29 | % 30 | % Authors: 31 | % Joan Pau Beltran 32 | 33 | % Copyright (C) 2014-2016 34 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 35 | % 36 | % 37 | % This program is free software: you can redistribute it and/or modify 38 | % it under the terms of the GNU General Public License as published by 39 | % the Free Software Foundation, either version 3 of the License, or 40 | % (at your option) any later version. 41 | % 42 | % This program is distributed in the hope that it will be useful, 43 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 44 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 | % GNU General Public License for more details. 46 | % 47 | % You should have received a copy of the GNU General Public License 48 | % along with this program. If not, see . 49 | 50 | narginchk(0, 3); 51 | 52 | if (nargin == 1) && isa(host, 'sftp') 53 | % Short circuit copy constructor. 54 | h = host; 55 | else 56 | switch nargin 57 | case 0 58 | host = []; 59 | username = []; 60 | password = []; 61 | case 1 62 | username = []; 63 | password = []; 64 | case 2 65 | password = []; 66 | end 67 | colon = find(host==':'); 68 | if isempty(colon) 69 | h.host = host; 70 | h.port = []; 71 | else 72 | h.host = host(1:colon-1); 73 | h.port = str2double(host(colon+1:end)); 74 | end 75 | h.username = username; 76 | h.password = password; 77 | h.sftp_handle = mexsftp('create', h.host, h.port, h.username, h.password); 78 | h.cleanup = onCleanup(@()(mexsftp('delete', h.sftp_handle))); 79 | h = class(h, 'sftp'); 80 | end 81 | 82 | end 83 | -------------------------------------------------------------------------------- /m/common_tools/posixtime2utc.m: -------------------------------------------------------------------------------- 1 | function d = posixtime2utc(s) 2 | %POSIXTIME2UTC Convert POSIX time to corresponding serial date number in UTC. 3 | % 4 | % Syntax: 5 | % D = POSIXTIME2UTC(S) 6 | % 7 | % Description: 8 | % D = POSIXTIME2UTC(S) returns the serial date numbers D corresponding 9 | % to the POSIX times in scalar, vector or array S, using the straight 10 | % forward method (see note below). 11 | % 12 | % Notes: 13 | % This function provides a compatibility interface for MATLAB and Octave, 14 | % computing the conversion using a straight forward linear scaling: 15 | % D = 719529 + S / 86400 16 | % This is consistent with the POSIX specification (not counting leap seconds, 17 | % using the same value for a leap second and its successor). 18 | % 19 | % Examples: 20 | % % Get the current UTC time. 21 | % d = posixtime2utc(posixtime()) 22 | % datestr(d) 23 | % % Built-in functions return always local time. 24 | % datestr(now()) 25 | % 26 | % See also: 27 | % POSIXTIME 28 | % UTC2POSIXTIME 29 | % 30 | % Authors: 31 | % Joan Pau Beltran 32 | 33 | % Copyright (C) 2013-2016 34 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 35 | % 36 | % 37 | % This program is free software: you can redistribute it and/or modify 38 | % it under the terms of the GNU General Public License as published by 39 | % the Free Software Foundation, either version 3 of the License, or 40 | % (at your option) any later version. 41 | % 42 | % This program is distributed in the hope that it will be useful, 43 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 44 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 | % GNU General Public License for more details. 46 | % 47 | % You should have received a copy of the GNU General Public License 48 | % along with this program. If not, see . 49 | 50 | narginchk(1, 1); 51 | 52 | d = 719529 + s / 86400; 53 | 54 | end 55 | -------------------------------------------------------------------------------- /m/common_tools/readConfigFile.m: -------------------------------------------------------------------------------- 1 | function [ readvals ] = readConfigFile( fconfig, varargin ) 2 | %READCONFIGFILE 3 | % TODO: Add description 4 | % This function should read the configuration file and return a structure 5 | % with the appropriate values from the text file 6 | % From https://rosettacode.org/wiki/Read_a_configuration_file#MATLAB_.2F_Octave 7 | % 8 | % Authors: 9 | % Miguel Charcos Llorens 10 | % 11 | % Copyright (C) 2013-2016 12 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 13 | % 14 | % 15 | % This program is free software: you can redistribute it and/or modify 16 | % it under the terms of the GNU General Public License as published by 17 | % the Free Software Foundation, either version 3 of the License, or 18 | % (at your option) any later version. 19 | % 20 | % This program is distributed in the hope that it will be useful, 21 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | % GNU General Public License for more details. 24 | % 25 | % You should have received a copy of the GNU General Public License 26 | % along with this program. If not, see . 27 | 28 | narginchk(1, 3); 29 | 30 | options.array_delimiter = '|'; 31 | 32 | %% Parse optional arguments. 33 | % Get option key-value pairs in any accepted call signature. 34 | argopts = varargin; 35 | if isscalar(argopts) && isstruct(argopts{1}) 36 | % Options passed as a single option struct argument: 37 | % field names are option keys and field values are option values. 38 | opt_key_list = fieldnames(argopts{1}); 39 | opt_val_list = struct2cell(argopts{1}); 40 | elseif mod(numel(argopts), 2) == 0 41 | % Options passed as key-value argument pairs. 42 | opt_key_list = argopts(1:2:end); 43 | opt_val_list = argopts(2:2:end); 44 | else 45 | error('glider_toolbox:readConfigFile:InvalidOptions', ... 46 | 'Invalid optional arguments (neither key-value pairs nor struct).'); 47 | end 48 | % Overwrite default options with values given in extra arguments. 49 | for opt_idx = 1:numel(opt_key_list) 50 | opt = lower(opt_key_list{opt_idx}); 51 | val = opt_val_list{opt_idx}; 52 | if isfield(options, opt) 53 | options.(opt) = val; 54 | else 55 | error('glider_toolbox:readConfigFile:InvalidOption', ... 56 | 'Invalid option: %s.', opt); 57 | end 58 | end 59 | 60 | %% Read configuration file 61 | fid = fopen(fconfig, 'rt'); 62 | if fid<0, error('cannot open file %s\n',fconfig); end; 63 | 64 | while ~feof(fid) 65 | line = strtrim(fgetl(fid)); 66 | 67 | % Reads only uncommented (# and ; symbols) and no-empty lines 68 | if isempty(line) || all(isspace(line)) || strncmp(line,'#',1) || strncmp(line,';',1), 69 | ; % no operation for commented line 70 | else 71 | %% Process valid lines of the configuration file 72 | % - split two sides of the equation (var = tok) 73 | % - Check whether the right side (tok) is an array or a single value 74 | % - Create a field readvals.(var) with the value (or array of values) 75 | [var,tok] = strtok(line,'='); 76 | var = strtrim(lower(var)); 77 | tok = strtrim(tok); 78 | tok = strtok(tok,'='); % remove = sign 79 | tok = strtrim(tok); 80 | if ~isempty(options.array_delimiter) && any(tok==options.array_delimiter), % for arrays 81 | k = 1; 82 | while (1) 83 | [val, tok]=strtok(tok,options.array_delimiter); 84 | %R.(var){k} = strtrim(val); % return value of function 85 | eval(sprintf('readvals.%s{%i}=''%s'';',var,k,strtrim(val))); % stores variable in local workspace 86 | if isempty(tok), break; end; 87 | k=k+1; 88 | end; 89 | else % for single value 90 | tok = strtrim(tok); 91 | %R.(var) = tok; % return value of function 92 | %sprintf('readvals.%s=''%s''; ',var,tok); 93 | 94 | % replaces ' character with '' in the tok value so it is evaluated correctly 95 | tok=strrep(tok,'''',''''''); 96 | eval(sprintf('readvals.%s=''%s''; ',var,tok)); % stores variable in local workspace 97 | end; 98 | end; 99 | end; 100 | 101 | fclose(fid); 102 | 103 | end 104 | 105 | -------------------------------------------------------------------------------- /m/common_tools/startLogging.m: -------------------------------------------------------------------------------- 1 | function [ ] = startLogging( log_file, gtb_version, deployment )%READCONFIGFILE 2 | % TODO: Add description 3 | % Use diary('off') to stop logging. 4 | % 5 | % Authors: 6 | % Miguel Charcos Llorens 7 | % 8 | % Copyright (C) 2013-2016 9 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 10 | % 11 | % 12 | % This program is free software: you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation, either version 3 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You should have received a copy of the GNU General Public License 23 | % along with this program. If not, see . 24 | 25 | 26 | narginchk(3, 3); 27 | 28 | %% Start deployment processing logging. 29 | % DIARY will fail if log file base directory does not exist. 30 | % Create the base directory first, if needed. 31 | % This is an ugly hack (the best known way) to check if the directory exists. 32 | [log_dir, ~, ~] = fileparts(log_file); 33 | [status, attrout] = fileattrib(log_dir); 34 | if ~status 35 | [status, message] = mkdir(log_dir); 36 | elseif ~attrout.directory 37 | status = false; 38 | message = 'not a directory'; 39 | end 40 | % Enable log only if directory was already there or has been created properly. 41 | if status 42 | try 43 | diary(log_file); 44 | diary('on'); 45 | catch exception 46 | disp(['Error enabling processing log diary ' log_file ':']); 47 | disp(getReport(exception, 'extended')); 48 | end 49 | else 50 | disp(['Error creating processing log directory ' log_dir ':']); 51 | disp(message); 52 | end 53 | disp(['Deployment processing start time: ' ... 54 | datestr(posixtime2utc(posixtime()), 'yyyy-mm-ddTHH:MM:SS+00:00')]); 55 | 56 | %% Report toolbox version: 57 | disp(['Toolbox version: ' gtb_version]); 58 | 59 | 60 | %% Report deployment information. 61 | if ~isempty(deployment) 62 | disp('Deployment information:') 63 | disp([' Glider name : ' deployment.glider_name]); 64 | disp([' Glider model : ' deployment.glider_model]); 65 | disp([' Glider serial : ' deployment.glider_serial]); 66 | disp([' Deployment identifier: ' num2str(deployment.deployment_id)]); 67 | disp([' Deployment name : ' deployment.deployment_name]); 68 | disp([' Deployment start : ' datestr(deployment.deployment_start)]); 69 | if isnan(deployment.deployment_end) 70 | disp([' Deployment end : ' 'undefined']); 71 | else 72 | disp([' Deployment end : ' datestr(deployment.deployment_end)]); 73 | end 74 | end 75 | 76 | end 77 | 78 | -------------------------------------------------------------------------------- /m/common_tools/strc.m: -------------------------------------------------------------------------------- 1 | function s = strc(c) 2 | %STRC Convert Matlab/OCTAVE char array to C string array. 3 | % 4 | % Syntax: 5 | % S = STRC(C) 6 | % 7 | % Description: 8 | % S = STRC(C) converts the blank padded char array C to a new char array S 9 | % with the same strings in its rows but as C strings (null terminated): 10 | % - always add a null character at the end of the string, and 11 | % - replace all trailing whitespace characters with null characters. 12 | % C may also be a string cell array and is converted to char array with CHAR. 13 | % 14 | % Notes: 15 | % The output char array S is always one column bigger than the input one C 16 | % (because function CHAR pads the shorter rows in a cell array up to the 17 | % length of the longest one). 18 | % 19 | % Examples: 20 | % c = {'- What''s that?'; ' ... '; ''; ' ... '; '- Surprise!!!'} 21 | % s = strc(c) 22 | % a = char(c) 23 | % uint8(a) 24 | % uint8(strc(c)) 25 | % 26 | % See also: 27 | % CHAR 28 | % CELLSTR 29 | % 30 | % Authors: 31 | % Joan Pau Beltran 32 | 33 | % Copyright (C) 2014-2016 34 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 35 | % 36 | % 37 | % This program is free software: you can redistribute it and/or modify 38 | % it under the terms of the GNU General Public License as published by 39 | % the Free Software Foundation, either version 3 of the License, or 40 | % (at your option) any later version. 41 | % 42 | % This program is distributed in the hope that it will be useful, 43 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 44 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 | % GNU General Public License for more details. 46 | % 47 | % You should have received a copy of the GNU General Public License 48 | % along with this program. If not, see . 49 | 50 | c = char(c); 51 | [m n] = size(c); 52 | s = char(ones(m, n+1, 'uint8') * 32); 53 | s(1:m, 1:n) = c; 54 | [v, i] = min(isspace(s(:,end:-1:1)), [], 2); 55 | z = bsxfun( @gt, 1:n+1, n - i + 2); 56 | z(v,:) = true; 57 | s(z) = 0; 58 | 59 | end 60 | -------------------------------------------------------------------------------- /m/common_tools/utc2posixtime.m: -------------------------------------------------------------------------------- 1 | function s = utc2posixtime(d) 2 | %UTC2POSIXTIME Convert serial date number in UTC to POSIX time. 3 | % 4 | % Syntax: 5 | % S = UTC2POSIXTIME(D) 6 | % 7 | % Description: 8 | % S = UTC2POSIXTIME(D) returns the POSIX times S corresponding to the serial 9 | % date numbers in scalar, vector or array D, using the straight forward 10 | % method (see note below). 11 | % 12 | % Notes: 13 | % This function provides a compatibility interface for MATLAB and Octave, 14 | % computing the conversion using a straight forward linear scaling: 15 | % S = 86400 * (D - 719529) 16 | % This is consistent with the POSIX specification (not counting leap seconds, 17 | % using the same value for a leap second and its successor). 18 | % 19 | % Examples: 20 | % % Compare the conversion of current time to the default shell current time. 21 | % tz_offset = -1; 22 | % s = utc2posixtime(now()+tz_offset/24) 23 | % ! date +%s%N 24 | % fprintf('%.0f\n',fix(1e+9*s)) 25 | % 26 | % See also: 27 | % POSIXTIME 28 | % POSIXTIME2UTC 29 | % 30 | % Authors: 31 | % Joan Pau Beltran 32 | 33 | % Copyright (C) 2013-2016 34 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 35 | % 36 | % 37 | % This program is free software: you can redistribute it and/or modify 38 | % it under the terms of the GNU General Public License as published by 39 | % the Free Software Foundation, either version 3 of the License, or 40 | % (at your option) any later version. 41 | % 42 | % This program is distributed in the hope that it will be useful, 43 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 44 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 | % GNU General Public License for more details. 46 | % 47 | % You should have received a copy of the GNU General Public License 48 | % along with this program. If not, see . 49 | 50 | narginchk(1, 1); 51 | 52 | s = 86400 * (d - 719529); 53 | 54 | end 55 | -------------------------------------------------------------------------------- /m/configBasestations.m: -------------------------------------------------------------------------------- 1 | function basestations = configBasestations() 2 | %CONFIGBASESTATIONS Configure basestation parameters for glider data processing. 3 | % 4 | % Syntax: 5 | % BASESTATIONS = CONFIGBASESTATIONS() 6 | % 7 | % Description: 8 | % BASESTATIONS = CONFIGBASESTATIONS() should return a struct array with the 9 | % access parameters for the basestations containing Seaglider glider data, as 10 | % needed by the function GETBASESTATIONFILES. 11 | % 12 | % Notes: 13 | % Edit this file filling in the parameters of your basestations. 14 | % Once configured, this file will contain private data, so you should not 15 | % make it public. 16 | % 17 | % Examples: 18 | % basestations = configBasestations() 19 | % 20 | % See also: 21 | % GETBASESTATIONFILES 22 | % 23 | % Authors: 24 | % Joan Pau Beltran 25 | 26 | % Copyright (C) 2014-2016 27 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 28 | % 29 | % 30 | % This program is free software: you can redistribute it and/or modify 31 | % it under the terms of the GNU General Public License as published by 32 | % the Free Software Foundation, either version 3 of the License, or 33 | % (at your option) any later version. 34 | % 35 | % This program is distributed in the hope that it will be useful, 36 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 37 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 38 | % GNU General Public License for more details. 39 | % 40 | % You should have received a copy of the GNU General Public License 41 | % along with this program. If not, see . 42 | 43 | narginchk(0, 0); 44 | 45 | basestations(1).url = 'http://mybasestation01.myportal.mydomain'; 46 | basestations(1).user = 'myself'; 47 | basestations(1).pass = 'top_secret'; 48 | 49 | basestations(2).url = 'http://mybasestation02.myportal.mydomain'; 50 | basestations(2).user = 'myself'; 51 | basestations(2).conn = @sftp; 52 | 53 | end 54 | -------------------------------------------------------------------------------- /m/configDTFileOptionsSeaExplorer.m: -------------------------------------------------------------------------------- 1 | function seaexplorer_options = configDTFileOptionsSeaExplorer() 2 | %CONFIGDTFILEOPTIONSSEAEXPLORER Configure loading options for SeaExplorer files in delayed time. 3 | % 4 | % Syntax: 5 | % SEAEXPLORER_OPTIONS = CONFIGDTFILEOPTIONSSEAEXPLORER() 6 | % 7 | % Description: 8 | % SEAEXPLORER_OPTIONS = CONFIGDTFILEOPTIONSSEAEXPLORER() should return 9 | % a struct with the parameters that control which are the deployment files, 10 | % whether they need to be converted, and which files and data should be used 11 | % in delayed time mode. The returned struct should have the following fields: 12 | % GLI_NAME_PATTERN: string with the name pattern of SeaExplorer glider 13 | % files to be loaded by LOADSEAEXPLORERDATA for processing. 14 | % PLD_NAME_PATTERN: string with the name pattern of SeaExplorer payload 15 | % files to be loaded by LOADSEAEXPLORERDATA for processing. 16 | % GLI_TIME: string with the name of the variable to use as timestamp 17 | % in glider files when combining data from a set of SeaExplorer files. 18 | % PLD_TIME: string with the name of the variable to use as timestamp 19 | % in payload files when combining data from a set of SeaExplorer files. 20 | % VARIABLES: string cell array with the name of the variables to load 21 | % from glider and payload files by LOADSEAEXPLORERDATA. Restricting 22 | % the list of variables to load may reduce the memory footprint. 23 | % 24 | % Examples: 25 | % seaexplorer_options = configDTFileOptionsSeaExplorer() 26 | % 27 | % See also: 28 | % MAIN_GLIDER_DATA_PROCESSING_DT 29 | % LOADSEAEXPLORERDATA 30 | % 31 | % Authors: 32 | % Frederic Cyr 33 | % Joan Pau Beltran 34 | 35 | % Copyright (C) 2016 36 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 37 | % 38 | % 39 | % This program is free software: you can redistribute it and/or modify 40 | % it under the terms of the GNU General Public License as published by 41 | % the Free Software Foundation, either version 3 of the License, or 42 | % (at your option) any later version. 43 | % 44 | % This program is distributed in the hope that it will be useful, 45 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 46 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 47 | % GNU General Public License for more details. 48 | % 49 | % You should have received a copy of the GNU General Public License 50 | % along with this program. If not, see . 51 | 52 | narginchk(0, 0); 53 | 54 | % Glider (.gli) files to use: 55 | seaexplorer_options.gli_name_pattern = '^.*\.gli(\..*)?$'; 56 | 57 | % Payload (.pld) files to use: 58 | % They used to have the suffix '.dat' during the SeaExplorer development. 59 | seaexplorer_options.pld_name_pattern = '^.*\.(pld|dat)(\d*)?(\..*)?$'; 60 | 61 | % Time variable column in glider files: 62 | seaexplorer_options.gli_time = 'Timestamp'; 63 | 64 | % Time variable column in payload files: 65 | seaexplorer_options.pld_time = 'PLD_REALTIMECLOCK'; 66 | 67 | % Variables to load: 68 | seaexplorer_options.variables = 'all'; 69 | 70 | end 71 | -------------------------------------------------------------------------------- /m/configDTFileOptionsSeaglider.m: -------------------------------------------------------------------------------- 1 | function seaglider_options = configDTFileOptionsSeaglider() 2 | %CONFIGDTFILEOPTIONSSEAGLIDER Configure loading options for Seaglider files in delayed time. 3 | % 4 | % Syntax: 5 | % SEAGLIDER_OPTIONS = CONFIGDTFILEOPTIONSSEAGLIDER() 6 | % 7 | % Description: 8 | % SEAGLIDER_OPTIONS = CONFIGDTFILEOPTIONSSEAGLIDER() should return a struct 9 | % with the parameters that control which are the deployment files, 10 | % whether they need to be converted, and which files and data should be used 11 | % in delayed time mode. The returned struct should have the following fields: 12 | % LOG_NAME_PATTERN: string with the name pattern of Seaglider log files 13 | % to be loaded by LOADSEAGLIDERDATA for processing. 14 | % ENG_NAME_PATTERN: string with the name pattern of Seaglider eng files. 15 | % to be loaded by LOADSEAGLIDERDATA for processing. 16 | % LOG_PARAMS: string cell array with the name of the parameters from 17 | % log files to be loaded by LOADSEAGLIDERDATA. Restricting the list of 18 | % parameters to load may reduce the memory footprint. 19 | % ENG_COLUMNS: string cell array with the name of the data columns from 20 | % eng files to be loaded by LOADSEAGLIDERDATA. Restricting the list of 21 | % columns to load may reduce the memory footprint. 22 | % 23 | % Examples: 24 | % seaglider_options = configDTFileOptionsSeaglider() 25 | % 26 | % See also: 27 | % MAIN_GLIDER_DATA_PROCESSING_DT 28 | % LOADSEAGLIDERDATA 29 | % 30 | % Authors: 31 | % Joan Pau Beltran 32 | 33 | % Copyright (C) 2013-2016 34 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 35 | % 36 | % 37 | % This program is free software: you can redistribute it and/or modify 38 | % it under the terms of the GNU General Public License as published by 39 | % the Free Software Foundation, either version 3 of the License, or 40 | % (at your option) any later version. 41 | % 42 | % This program is distributed in the hope that it will be useful, 43 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 44 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 | % GNU General Public License for more details. 46 | % 47 | % You should have received a copy of the GNU General Public License 48 | % along with this program. If not, see . 49 | 50 | narginchk(0, 0); 51 | 52 | % Select dive log files to use. All log files: 53 | seaglider_options.log_name_pattern = '^p\d{3}\d{4}\.log$'; 54 | 55 | % Select dive eng files to use. All eng files: 56 | seaglider_options.eng_name_pattern = '^p\d{3}\d{4}\.eng$'; 57 | 58 | % Log parameters to load. 59 | seaglider_options.log_params = 'all'; 60 | 61 | % Eng parameters to load. 62 | seaglider_options.eng_columns = 'all'; 63 | 64 | end 65 | -------------------------------------------------------------------------------- /m/configDataGridding.m: -------------------------------------------------------------------------------- 1 | function gridding_options = configDataGridding() 2 | %CONFIGDATAGRIDDING Configure glider data gridding. 3 | % 4 | % Syntax: 5 | % GRIDDING_OPTIONS = CONFIGDATAGRIDDING() 6 | % 7 | % Description: 8 | % GRIDDING_OPTIONS = CONFIGDATAGRIDDING() should return a struct setting the 9 | % options for glider data gridding as needed by the function GRIDGLIDERDATA. 10 | % 11 | % Examples: 12 | % gridding_options = configDataGridding() 13 | % 14 | % See also: 15 | % GRIDGLIDERDATA 16 | % 17 | % Authors: 18 | % Joan Pau Beltran 19 | 20 | % Copyright (C) 2013-2016 21 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 22 | % 23 | % 24 | % This program is free software: you can redistribute it and/or modify 25 | % it under the terms of the GNU General Public License as published by 26 | % the Free Software Foundation, either version 3 of the License, or 27 | % (at your option) any later version. 28 | % 29 | % This program is distributed in the hope that it will be useful, 30 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 31 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 32 | % GNU General Public License for more details. 33 | % 34 | % You should have received a copy of the GNU General Public License 35 | % along with this program. If not, see . 36 | 37 | narginchk(0, 0); 38 | 39 | gridding_options = struct(); 40 | 41 | gridding_options.profile_list = {'profile_index'}; 42 | 43 | gridding_options.time_list = {'time'}; 44 | 45 | gridding_options.position_list(1).latitude = 'latitude'; 46 | gridding_options.position_list(1).longitude = 'longitude'; 47 | 48 | gridding_options.depth_list = {'depth' 'depth_ctd'}; 49 | 50 | gridding_options.depth_step = 1; 51 | 52 | gridding_options.variable_list = { 53 | 'conductivity' 54 | 'temperature' 55 | 'pressure' 56 | 'chlorophyll' 57 | 'turbidity' 58 | 'cdom' 59 | 'scatter_650' 60 | 'backscatter_700' 61 | 'oxygen_concentration' 62 | 'oxygen_saturation' 63 | 'oxygen_frequency' 64 | 'conductivity_corrected_thermal' 65 | 'temperature_corrected_thermal' 66 | 'salinity' 67 | 'density' 68 | 'salinity_corrected_thermal' 69 | 'density_corrected_thermal' 70 | 'fluorescence_255_360' 71 | 'fluorescence_260_315' 72 | 'fluorescence_270_340' 73 | 'fluorescence_270_376' 74 | 'fluorescence_monitoring_255_360' 75 | 'fluorescence_monitoring_260_315' 76 | 'fluorescence_monitoring_270_340' 77 | 'fluorescence_monitoring_270_376' 78 | 'methane_concentration' 79 | }; 80 | 81 | end 82 | -------------------------------------------------------------------------------- /m/configDataPreprocessingSeaglider.m: -------------------------------------------------------------------------------- 1 | function preprocessing_options = configDataPreprocessingSeaglider() 2 | %CONFIGDATAPREPROCESSINGSEAGLIDER Configure Seaglider glider data preprocessing. 3 | % 4 | % Syntax: 5 | % PREPROCESSING_OPTIONS = CONFIGDATAPREPROCESSINGSEAGLIDER() 6 | % 7 | % Description: 8 | % PREPROCESSING_OPTIONS = CONFIGDATAPREPROCESSINGSEAGLIDER() should return 9 | % a struct setting the options for Seaglider glider data preprocessing 10 | % as needed by the function PREPROCESSGLIDERDATA. 11 | % 12 | % Examples: 13 | % preprocessing_options = configDataPreprocessingSeaglider() 14 | % 15 | % See also: 16 | % PREPROCESSGLIDERDATA 17 | % 18 | % Authors: 19 | % Joan Pau Beltran 20 | 21 | % Copyright (C) 2013-2016 22 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 23 | % 24 | % 25 | % This program is free software: you can redistribute it and/or modify 26 | % it under the terms of the GNU General Public License as published by 27 | % the Free Software Foundation, either version 3 of the License, or 28 | % (at your option) any later version. 29 | % 30 | % This program is distributed in the hope that it will be useful, 31 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 | % GNU General Public License for more details. 34 | % 35 | % You should have received a copy of the GNU General Public License 36 | % along with this program. If not, see . 37 | 38 | narginchk(0, 0); 39 | 40 | preprocessing_options = struct(); 41 | 42 | preprocessing_options.sg_dive_params = { ... 43 | 'TGT_LATLONG_tgt_lon' 'TGT_LATLONG_tgt_lat' ... 44 | 'CURRENT_cur_dir' 'CURRENT_cur_spd' 'CURRENT_cur_val' }; 45 | 46 | preprocessing_options.time_list(1).time = 'elaps_t'; 47 | 48 | preprocessing_options.position_list(1).longitude = 'GPSFIX_fixlon'; 49 | preprocessing_options.position_list(1).latitude = 'GPSFIX_fixlat'; 50 | preprocessing_options.position_list(1).conversion = @nmea2deg; 51 | preprocessing_options.position_list(1).date = 'GPSFIX_ddmmyy'; 52 | preprocessing_options.position_list(1).time = 'GPSFIX_hhmmss'; 53 | preprocessing_options.position_list(1).time_conversion = ... 54 | @(d,t)(utc2posixtime(fillSGMissingGPSDate(d,t))); 55 | 56 | preprocessing_options.depth_list(1).depth = 'depth'; 57 | preprocessing_options.depth_list(1).conversion = @cm2m; 58 | 59 | preprocessing_options.attitude_list(1).roll = 'rollAng'; 60 | preprocessing_options.attitude_list(1).pitch = 'pitchAng'; 61 | preprocessing_options.attitude_list(1).conversion = @deg2rad; 62 | 63 | preprocessing_options.heading_list(1).heading = 'head'; 64 | preprocessing_options.heading_list(1).conversion = @deg2rad; 65 | 66 | preprocessing_options.waypoint_list(1).longitude = 'TGT_LATLONG_tgt_lon'; 67 | preprocessing_options.waypoint_list(1).latitude = 'TGT_LATLONG_tgt_lat'; 68 | preprocessing_options.waypoint_list(1).conversion = @nmea2deg; 69 | 70 | preprocessing_options.water_velocity_list(1).velocity_eastward = 'CURRENT_cur_spd'; 71 | preprocessing_options.water_velocity_list(1).velocity_northward = 'CURRENT_cur_dir'; 72 | preprocessing_options.water_velocity_list(1).conversion = @sgcur2cart; 73 | 74 | preprocessing_options.ctd_list(1).conductivity = 'sbect_condFreq'; 75 | preprocessing_options.ctd_list(1).temperature = 'sbect_tempFreq'; 76 | preprocessing_options.ctd_list(1).pressure = 'depth'; 77 | preprocessing_options.ctd_list(1).pressure_conversion = @sgdepth2pres; 78 | preprocessing_options.ctd_list(1).calibration = @calibrateSBECT; 79 | 80 | preprocessing_options.oxygen_list(1).oxygen_concentration = 'aa1_O2'; 81 | preprocessing_options.oxygen_list(1).oxygen_saturation = 'aa1_AirSat'; 82 | preprocessing_options.oxygen_list(1).temperature = 'aa1_Temp'; 83 | 84 | preprocessing_options.optics_list(1).chlorophyll = 'wl1_Chlsig1'; 85 | preprocessing_options.optics_list(1).cdom = 'wl1_Cdomsig1'; 86 | preprocessing_options.optics_list(1).scatter_650 = 'wl1_sig1'; 87 | preprocessing_options.optics_list(1).calibration = 'calibrateWLECOBbFl2'; 88 | preprocessing_options.optics_list(2).chlorophyll = 'wlbbfl2vmt_Chlsig'; 89 | preprocessing_options.optics_list(2).cdom = 'wlbbfl2vmt_Cdomsig'; 90 | preprocessing_options.optics_list(2).scatter_650 = 'wlbbfl2vmt_wl650sig'; 91 | preprocessing_options.optics_list(2).calibration = 'calibrateWLECOBbFl2'; 92 | preprocessing_options.optics_list(3).chlorophyll = 'wlbbfl2vmt_Chlsig'; 93 | preprocessing_options.optics_list(3).cdom = 'wlbbfl2vmt_Cdomsig'; 94 | preprocessing_options.optics_list(3).scatter_650 = 'wlbbfl2vmt_wl600sig'; 95 | preprocessing_options.optics_list(3).calibration = 'calibrateWLECOBbFl2'; 96 | 97 | preprocessing_options.extra_sensor_list = struct(); 98 | 99 | end 100 | 101 | -------------------------------------------------------------------------------- /m/configDataPreprocessingSlocum.m: -------------------------------------------------------------------------------- 1 | function preprocessing_options = configDataPreprocessingSlocum() 2 | %CONFIGDATAPREPROCESSINGSLOCUM Configure Slocum glider data preprocessing. 3 | % 4 | % Syntax: 5 | % PREPROCESSING_OPTIONS = CONFIGDATAPREPROCESSINGSLOCUM() 6 | % 7 | % Description: 8 | % PREPROCESSING_OPTIONS = CONFIGDATAPREPROCESSINGSLOCUM() should return a 9 | % struct setting the options for Slocum glider data preprocessing as needed 10 | % by the function PREPROCESSGLIDERDATA. 11 | % 12 | % Examples: 13 | % processing_options = configDataPreprocessingSlocum() 14 | % 15 | % See also: 16 | % PREPROCESSGLIDERDATA 17 | % 18 | % Authors: 19 | % Joan Pau Beltran 20 | 21 | % Copyright (C) 2013-2016 22 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 23 | % 24 | % 25 | % This program is free software: you can redistribute it and/or modify 26 | % it under the terms of the GNU General Public License as published by 27 | % the Free Software Foundation, either version 3 of the License, or 28 | % (at your option) any later version. 29 | % 30 | % This program is distributed in the hope that it will be useful, 31 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 | % GNU General Public License for more details. 34 | % 35 | % You should have received a copy of the GNU General Public License 36 | % along with this program. If not, see . 37 | 38 | narginchk(0, 0); 39 | 40 | preprocessing_options = struct(); 41 | 42 | preprocessing_options.time_list(1).time = 'm_present_time'; 43 | preprocessing_options.time_list(2).time = 'sci_m_present_time'; 44 | 45 | preprocessing_options.position_list(1).longitude = 'm_gps_lon'; 46 | preprocessing_options.position_list(1).latitude = 'm_gps_lat'; 47 | preprocessing_options.position_list(1).conversion = @nmea2deg; 48 | preprocessing_options.position_list(1).position_status = 'm_gps_status'; 49 | preprocessing_options.position_list(1).position_good = 0; 50 | preprocessing_options.position_list(2).longitude = 'm_lon'; 51 | preprocessing_options.position_list(2).latitude = 'm_lat'; 52 | preprocessing_options.position_list(2).conversion = @nmea2deg; 53 | 54 | preprocessing_options.depth_list.depth = 'm_depth'; 55 | 56 | preprocessing_options.attitude_list(1).roll = 'm_roll'; 57 | preprocessing_options.attitude_list(1).pitch = 'm_pitch'; 58 | 59 | preprocessing_options.heading_list.heading = 'm_heading'; 60 | 61 | preprocessing_options.waypoint_list(1).longitude = 'c_wpt_lon'; 62 | preprocessing_options.waypoint_list(1).latitude = 'c_wpt_lat'; 63 | preprocessing_options.waypoint_list(1).conversion = @nmea2deg; 64 | 65 | preprocessing_options.water_velocity_list(1).velocity_eastward = 'm_final_water_vx'; 66 | preprocessing_options.water_velocity_list(1).velocity_northward = 'm_final_water_vy'; 67 | 68 | preprocessing_options.ctd_list(1).conductivity = 'sci_water_cond'; 69 | preprocessing_options.ctd_list(1).temperature = 'sci_water_temp'; 70 | preprocessing_options.ctd_list(1).pressure = 'sci_water_pressure'; 71 | preprocessing_options.ctd_list(1).time = 'sci_ctd41cp_timestamp'; 72 | preprocessing_options.ctd_list(1).pressure_conversion = @bar2dbar; 73 | 74 | preprocessing_options.ctd_list(2).conductivity = 'm_water_cond'; 75 | preprocessing_options.ctd_list(2).temperature = 'm_water_temp'; 76 | preprocessing_options.ctd_list(2).pressure = 'm_water_pressure'; 77 | preprocessing_options.ctd_list(2).time = []; 78 | preprocessing_options.ctd_list(2).pressure_conversion = @bar2dbar; 79 | 80 | preprocessing_options.oxygen_list(1).oxygen_concentration = 'sci_oxy3835_oxygen'; 81 | preprocessing_options.oxygen_list(1).oxygen_saturation = 'sci_oxy3835_saturation'; 82 | preprocessing_options.oxygen_list(1).temperature = 'sci_oxy3835_temp'; 83 | preprocessing_options.oxygen_list(1).time = 'sci_oxy3835_timestamp'; 84 | 85 | % options for FMI sensors 86 | preprocessing_options.oxygen_list(2).oxygen_concentration = 'sci_oxy4_oxygen'; 87 | preprocessing_options.oxygen_list(2).oxygen_saturation = 'sci_oxy4_saturation'; 88 | preprocessing_options.oxygen_list(2).temperature = 'sci_oxy4_temp'; 89 | preprocessing_options.oxygen_list(2).time = 'sci_oxy4_timestamp'; 90 | 91 | preprocessing_options.optics_list(1).chlorophyll = 'sci_flntu_chlor_units'; 92 | preprocessing_options.optics_list(1).turbidity = 'sci_flntu_turb_units'; 93 | preprocessing_options.optics_list(1).temperature = 'sci_flntu_temp'; 94 | preprocessing_options.optics_list(1).time = 'sci_flntu_timestamp'; 95 | 96 | preprocessing_options.extra_sensor_list = struct(); 97 | 98 | end 99 | 100 | -------------------------------------------------------------------------------- /m/configDataProcessingSeaExplorer.m: -------------------------------------------------------------------------------- 1 | function processing_options = configDataProcessingSeaExplorer() 2 | %CONFIGDATAPROCESSINGSEAEXPLORER Configure SeaExplorer glider data processing. 3 | % 4 | % Syntax: 5 | % PROCESSING_OPTIONS = CONFIGDATAPROCESSINGSEAEXPLORER() 6 | % 7 | % Description: 8 | % PROCESSING_OPTIONS = CONFIGDATAPROCESSINGSEAEXPLORER() should return a 9 | % struct setting the options for SeaExplorer glider data processing as needed 10 | % by the function PROCESSGLIDERDATA. 11 | % 12 | % Examples: 13 | % processing_options = configDataProcessingSeaExplorer() 14 | % 15 | % See also: 16 | % PROCESSGLIDERDATA 17 | % 18 | % Authors: 19 | % Frederic Cyr 20 | % Joan Pau Beltran 21 | 22 | % Copyright (C) 2016 23 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 24 | % 25 | % 26 | % This program is free software: you can redistribute it and/or modify 27 | % it under the terms of the GNU General Public License as published by 28 | % the Free Software Foundation, either version 3 of the License, or 29 | % (at your option) any later version. 30 | % 31 | % This program is distributed in the hope that it will be useful, 32 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 33 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 34 | % GNU General Public License for more details. 35 | % 36 | % You should have received a copy of the GNU General Public License 37 | % along with this program. If not, see . 38 | 39 | narginchk(0, 0); 40 | 41 | processing_options = struct(); 42 | 43 | processing_options.time_filling = true; 44 | processing_options.position_filling = true; 45 | processing_options.depth_filling = true; 46 | processing_options.attitude_filling = true; 47 | processing_options.heading_filling = true; 48 | processing_options.waypoint_filling = false; 49 | 50 | processing_options.pressure_filtering = true; 51 | processing_options.pressure_filter_constant = 4; % Recommended setting from Seabird Data Processing Manual. 52 | processing_options.depth_ctd_derivation = true; 53 | 54 | processing_options.profiling_list(1).depth = 'depth_ctd'; 55 | processing_options.profiling_list(1).time = 'time'; 56 | processing_options.profiling_list(2).depth = 'depth'; 57 | processing_options.profiling_list(2).time = 'time'; 58 | 59 | processing_options.profile_min_range = 10; 60 | processing_options.profile_max_gap_ratio = 0.6; 61 | 62 | processing_options.sensor_lag_list = ... 63 | struct('corrected', {}, 'original', {}, 'parameters', {}); 64 | 65 | processing_options.thermal_lag_list = ... 66 | struct('conductivity_corrected', {}, 'temperature_corrected', {}, ... 67 | 'conductivity_original', {}, 'temperature_original', {}, ... 68 | 'pressure_original', {}, 'parameters', {}); 69 | 70 | processing_options.salinity_list(1).salinity = 'salinity'; 71 | processing_options.salinity_list(1).conductivity = 'conductivity'; 72 | processing_options.salinity_list(1).temperature = 'temperature'; 73 | processing_options.salinity_list(1).pressure = 'pressure'; 74 | 75 | processing_options.density_list(1).density = 'density'; 76 | processing_options.density_list(1).salinity = 'salinity'; 77 | processing_options.density_list(1).temperature = 'temperature'; 78 | processing_options.density_list(1).pressure = 'pressure'; 79 | 80 | end 81 | -------------------------------------------------------------------------------- /m/configDataProcessingSeaglider.m: -------------------------------------------------------------------------------- 1 | function processing_options = configDataProcessingSeaglider() 2 | %CONFIGDATAPROCESSINGSEAGLIDER Configure Seaglider glider data processing. 3 | % 4 | % Syntax: 5 | % PROCESSING_OPTIONS = CONFIGDATAPROCESSINGSEAGLIDER() 6 | % 7 | % Description: 8 | % PROCESSING_OPTIONS = CONFIGDATAPROCESSINGSEAGLIDER() should return a struct 9 | % setting the options for Seaglider glider data processing as needed by the 10 | % function PROCESSGLIDERDATA. 11 | % 12 | % Examples: 13 | % processing_options = configDataProcessingSeaglider() 14 | % 15 | % See also: 16 | % PROCESSGLIDERDATA 17 | % 18 | % Authors: 19 | % Joan Pau Beltran 20 | 21 | % Copyright (C) 2013-2016 22 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 23 | % 24 | % 25 | % This program is free software: you can redistribute it and/or modify 26 | % it under the terms of the GNU General Public License as published by 27 | % the Free Software Foundation, either version 3 of the License, or 28 | % (at your option) any later version. 29 | % 30 | % This program is distributed in the hope that it will be useful, 31 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 | % GNU General Public License for more details. 34 | % 35 | % You should have received a copy of the GNU General Public License 36 | % along with this program. If not, see . 37 | 38 | narginchk(0, 0); 39 | 40 | processing_options = struct(); 41 | 42 | processing_options.time_filling = true; 43 | processing_options.position_filling = true; 44 | processing_options.depth_filling = true; 45 | processing_options.attitude_filling = true; 46 | processing_options.heading_filling = true; 47 | processing_options.waypoint_filling = true; 48 | 49 | processing_options.pressure_filtering = true; 50 | processing_options.pressure_filter_constant = 4; % Recommended setting from Seabird Data Processing Manual. 51 | processing_options.depth_ctd_derivation = true; 52 | 53 | processing_options.profiling_list(1).depth = 'depth_ctd'; 54 | processing_options.profiling_list(1).time = 'time'; 55 | processing_options.profiling_list(2).depth = 'depth'; 56 | processing_options.profiling_list(2).time = 'time'; 57 | % Use default values for profile identification parameters: 58 | % stall (3), inversion (3), and length (10), and 59 | % shake (20), interrupt (180), and period (0). 60 | 61 | processing_options.profile_min_range = 10; 62 | processing_options.profile_max_gap_ratio = 0.6; 63 | 64 | processing_options.flow_ctd_list(1).time = 'time_ctd'; 65 | processing_options.flow_ctd_list(1).depth = 'depth_ctd'; 66 | processing_options.flow_ctd_list(1).pitch = 'pitch'; 67 | processing_options.flow_ctd_list(2).time = 'time'; 68 | processing_options.flow_ctd_list(2).depth = 'depth_ctd'; 69 | processing_options.flow_ctd_list(2).pitch = 'pitch'; 70 | processing_options.flow_ctd_list(3).time = 'time'; 71 | processing_options.flow_ctd_list(3).depth = 'depth'; 72 | processing_options.flow_ctd_list(3).pitch = 'pitch'; 73 | processing_options.flow_ctd_pitch_value = []; 74 | processing_options.flow_ctd_min_pitch = deg2rad(11); 75 | processing_options.flow_ctd_min_velocity = 0.05; 76 | 77 | processing_options.sensor_lag_list = ... 78 | struct('corrected', {}, 'original', {}, 'parameters', {}); 79 | 80 | processing_options.thermal_lag_list = ... 81 | struct('conductivity_corrected', {}, 'temperature_corrected', {}, ... 82 | 'conductivity_original', {}, 'temperature_original', {}, ... 83 | 'pressure_original', {}, 'parameters', {}); 84 | 85 | processing_options.thermal_lag_list(1).conductivity_corrected = 'conductivity_corrected_thermal'; 86 | processing_options.thermal_lag_list(1).temperature_corrected = 'temperature_corrected_thermal'; 87 | processing_options.thermal_lag_list(1).conductivity_original = 'conductivity'; 88 | processing_options.thermal_lag_list(1).temperature_original = 'temperature'; 89 | processing_options.thermal_lag_list(1).pressure_original = 'pressure'; 90 | processing_options.thermal_lag_list(1).constant_flow = false; 91 | processing_options.thermal_lag_list(1).parameters = 'auto'; 92 | processing_options.thermal_lag_list(1).estimator = @nanmedian; 93 | processing_options.thermal_lag_list(1).minopts = struct(); 94 | 95 | processing_options.salinity_list(1).salinity = 'salinity'; 96 | processing_options.salinity_list(1).conductivity = 'conductivity'; 97 | processing_options.salinity_list(1).temperature = 'temperature'; 98 | processing_options.salinity_list(1).pressure = 'pressure'; 99 | processing_options.salinity_list(2).salinity = 'salinity_corrected_thermal'; 100 | processing_options.salinity_list(2).conductivity = 'conductivity'; 101 | processing_options.salinity_list(2).temperature = 'temperature_corrected_thermal'; 102 | processing_options.salinity_list(2).pressure = 'pressure'; 103 | 104 | processing_options.density_list(1).density = 'density'; 105 | processing_options.density_list(1).salinity = 'salinity'; 106 | processing_options.density_list(1).temperature = 'temperature'; 107 | processing_options.density_list(1).pressure = 'pressure'; 108 | processing_options.density_list(2).density = 'density_corrected_thermal'; 109 | processing_options.density_list(2).salinity = 'salinity_corrected_thermal'; 110 | processing_options.density_list(2).temperature = 'temperature'; 111 | processing_options.density_list(2).pressure = 'pressure'; 112 | 113 | end 114 | -------------------------------------------------------------------------------- /m/configDataProcessingSlocumG2.m: -------------------------------------------------------------------------------- 1 | function processing_options = configDataProcessingSlocumG2() 2 | %CONFIGDATAPROCESSINGSLOCUMG1 Configure Slocum G1 glider data processing. 3 | % 4 | % Syntax: 5 | % PROCESSING_OPTIONS = CONFIGDATAPROCESSINGSLOCUMG2() 6 | % 7 | % Description: 8 | % PROCESSING_OPTIONS = CONFIGDATAPROCESSINGSLOCUMG2() should return a struct 9 | % setting the options for Slocum G2 glider data processing as needed by the 10 | % function PROCESSGLIDERDATA. 11 | % 12 | % Examples: 13 | % processing_options = configDataProcessingSlocumG2() 14 | % 15 | % See also: 16 | % PROCESSGLIDERDATA 17 | % 18 | % Authors: 19 | % Joan Pau Beltran 20 | 21 | % Copyright (C) 2013-2016 22 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 23 | % 24 | % 25 | % This program is free software: you can redistribute it and/or modify 26 | % it under the terms of the GNU General Public License as published by 27 | % the Free Software Foundation, either version 3 of the License, or 28 | % (at your option) any later version. 29 | % 30 | % This program is distributed in the hope that it will be useful, 31 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 | % GNU General Public License for more details. 34 | % 35 | % You should have received a copy of the GNU General Public License 36 | % along with this program. If not, see . 37 | 38 | narginchk(0, 0); 39 | 40 | processing_options = struct(); 41 | 42 | processing_options.time_filling = true; 43 | processing_options.position_filling = true; 44 | processing_options.depth_filling = true; 45 | processing_options.attitude_filling = true; 46 | processing_options.heading_filling = true; 47 | processing_options.waypoint_filling = true; 48 | 49 | processing_options.pressure_filtering = true; 50 | processing_options.pressure_filter_constant = 4; % Recommended setting from Seabird Data Processing Manual. 51 | processing_options.depth_ctd_derivation = true; 52 | 53 | processing_options.profiling_list(1).depth = 'depth'; 54 | processing_options.profiling_list(1).time = 'time'; 55 | processing_options.profiling_list(2).depth = 'depth_ctd'; 56 | processing_options.profiling_list(2).time = 'time_ctd'; 57 | processing_options.profiling_list(3).depth = 'depth_ctd'; 58 | processing_options.profiling_list(3).time = 'time'; 59 | % Use default values for profile identification parameters: 60 | % stall (3), inversion (3), and length (10), and 61 | % shake (20), interrupt (180), and period (0). 62 | 63 | processing_options.profile_min_range = 10; 64 | processing_options.profile_max_gap_ratio = 0.6; 65 | 66 | processing_options.sensor_lag_list = ... 67 | struct('corrected', {}, 'original', {}, 'parameters', {}); 68 | 69 | processing_options.thermal_lag_list = ... 70 | struct('conductivity_corrected', {}, 'temperature_corrected', {}, ... 71 | 'conductivity_original', {}, 'temperature_original', {}, ... 72 | 'pressure_original', {}, 'parameters', {}); 73 | 74 | processing_options.salinity_list(1).salinity = 'salinity'; 75 | processing_options.salinity_list(1).conductivity = 'conductivity'; 76 | processing_options.salinity_list(1).temperature = 'temperature'; 77 | processing_options.salinity_list(1).pressure = 'pressure'; 78 | 79 | processing_options.density_list(1).density = 'density'; 80 | processing_options.density_list(1).salinity = 'salinity'; 81 | processing_options.density_list(1).temperature = 'temperature'; 82 | processing_options.density_list(1).pressure = 'pressure'; 83 | 84 | end 85 | -------------------------------------------------------------------------------- /m/configGliderToolboxPath.m: -------------------------------------------------------------------------------- 1 | function [glider_toolbox_dir] = configGliderToolboxPath() 2 | %CONFIGGLIDERTOOLBOXPATH Configure path to include the glider toolbox. 3 | % 4 | % Syntax: 5 | % GLIDER_TOOLBOX_DIR = CONFIGGLIDERTOOLBOXPATH() 6 | % 7 | % Description: 8 | % GLIDER_TOOLBOX_DIR = CONFIGGLIDERTOOLBOXPATH() adds the directory 9 | % containing this function and all its subdirectories to the workspace 10 | % path and returns the full directory path. 11 | % 12 | % Examples: 13 | % glider_toolbox_dir = configGliderToolboxPath() 14 | % 15 | % Authors: 16 | % Joan Pau Beltran 17 | 18 | % Copyright (C) 2013-2016 19 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 20 | % 21 | % 22 | % This program is free software: you can redistribute it and/or modify 23 | % it under the terms of the GNU General Public License as published by 24 | % the Free Software Foundation, either version 3 of the License, or 25 | % (at your option) any later version. 26 | % 27 | % This program is distributed in the hope that it will be useful, 28 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 | % GNU General Public License for more details. 31 | % 32 | % You should have received a copy of the GNU General Public License 33 | % along with this program. If not, see . 34 | 35 | narginchk(0, 0); 36 | 37 | [glider_toolbox_dir, ~, ~] = fileparts(mfilename('fullpath')); 38 | addpath(genpath(glider_toolbox_dir)); 39 | 40 | glider_toolbox_dir = fullfile(glider_toolbox_dir, '..'); 41 | curDir = pwd(); 42 | cd(glider_toolbox_dir); 43 | glider_toolbox_dir = pwd(); 44 | cd(curDir); 45 | 46 | end 47 | -------------------------------------------------------------------------------- /m/configGliderToolboxVersion.m: -------------------------------------------------------------------------------- 1 | function version = configGliderToolboxVersion(varargin) 2 | %CONFIGGLIDERTOOLBOXVERSION Configure version of the currently toolbox in use. 3 | % 4 | % Syntax: 5 | % VERSION = CONFIGGLIDERTOOLBOXVERSION() 6 | % 7 | % Description: 8 | % VERSION = CONFIGGLIDERTOOLBOXVERSION() should return the identifier 9 | % of the current version of the toolbox (see note on versions below). 10 | % Optionally, users may call configGliderToolboxVersion(format) to get a 11 | % different format of the version as shown in the following example: 12 | % - default: 1.2.3 13 | % - main: 1.2 14 | % - short: 123 (less than 4 characters) 15 | % the short format of the version (less than 4 characters) 16 | % 17 | % Notes: 18 | % It is highly recommended to modify the returned version when using a forked 19 | % version of the toolbox. The recommended way is to compose the custom 20 | % version identifier by adding a suffix to the identifier of the version on 21 | % which the fork is based separated by a hyphen. If your version is on a 22 | % public repository under version control, it might be useful to use the same 23 | % reference identifier (branch and commit id, tag, revision...) as suffix. 24 | % 25 | % Examples: 26 | % version = configGliderToolboxVersion() 27 | % 28 | % Authors: 29 | % Joan Pau Beltran 30 | 31 | % Copyright (C) 2014-2016 32 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 33 | % 34 | % 35 | % This program is free software: you can redistribute it and/or modify 36 | % it under the terms of the GNU General Public License as published by 37 | % the Free Software Foundation, either version 3 of the License, or 38 | % (at your option) any later version. 39 | % 40 | % This program is distributed in the hope that it will be useful, 41 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | % GNU General Public License for more details. 44 | % 45 | % You should have received a copy of the GNU General Public License 46 | % along with this program. If not, see . 47 | 48 | narginchk(0, 1); 49 | 50 | version = '1.3.1'; 51 | 52 | if nargin > 0 53 | switch varargin{1} 54 | case 'short' 55 | version = '130'; 56 | case 'main' 57 | version = '1.3'; 58 | otherwise 59 | ; 60 | end 61 | end 62 | 63 | end 64 | -------------------------------------------------------------------------------- /m/configRTFileOptionsSeaExplorer.m: -------------------------------------------------------------------------------- 1 | function seaexplorer_options = configRTFileOptionsSeaExplorer() 2 | %CONFIGRTFILEOPTIONSSEAEXPLORER Configure loading options for SeaExplorer files in real time. 3 | % 4 | % Syntax: 5 | % SEAEXPLORER_OPTIONS = CONFIGRTFILEOPTIONSSEAEXPLORER() 6 | % 7 | % Description: 8 | % SEAEXPLORER_OPTIONS = CONFIGRTFILEOPTIONSSEAEXPLORER() should return 9 | % a struct with the parameters that control which are the deployment files, 10 | % whether they need to be converted, and which files and data should be used 11 | % in delayed time mode. The returned struct should have the following fields: 12 | % GLI_NAME_PATTERN: string with the name pattern of SeaExplorer glider 13 | % files to be loaded by LOADSEAEXPLORERDATA for processing. 14 | % PLD_NAME_PATTERN: string with the name pattern of SeaExplorer payload 15 | % files to be loaded by LOADSEAEXPLORERDATA for processing. 16 | % GLI_TIME: string with the name of the variable to use as timestamp 17 | % in glider files when combining data from a set of SeaExplorer files. 18 | % PLD_TIME: string with the name of the variable to use as timestamp 19 | % in payload files when combining data from a set of SeaExplorer files. 20 | % VARIABLES: string cell array with the name of the variables to load 21 | % from glider and payload files by LOADSEAEXPLORERDATA. Restricting 22 | % the list of variables to load may reduce the memory footprint. 23 | % 24 | % Examples: 25 | % seaexplorer_options = configRTFileOptionsSeaExplorer() 26 | % 27 | % See also: 28 | % MAIN_GLIDER_DATA_PROCESSING_RT 29 | % LOADSEAEXPLORERDATA 30 | % 31 | % Authors: 32 | % Frederic Cyr 33 | % Joan Pau Beltran 34 | 35 | % Copyright (C) 2016 36 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 37 | % 38 | % 39 | % This program is free software: you can redistribute it and/or modify 40 | % it under the terms of the GNU General Public License as published by 41 | % the Free Software Foundation, either version 3 of the License, or 42 | % (at your option) any later version. 43 | % 44 | % This program is distributed in the hope that it will be useful, 45 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 46 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 47 | % GNU General Public License for more details. 48 | % 49 | % You should have received a copy of the GNU General Public License 50 | % along with this program. If not, see . 51 | 52 | narginchk(0, 0); 53 | 54 | % Glider (.gli) files to use: 55 | seaexplorer_options.gli_name_pattern = '^.*\.gli(\..*)?$'; 56 | 57 | % Payload (.pld) files to use: 58 | % They used to have the suffix '.dat' during the SeaExplorer development. 59 | seaexplorer_options.pld_name_pattern = '^.*\.(pld|dat)(\d*)?(\..*)?$'; 60 | 61 | % Time variable column in glider files: 62 | seaexplorer_options.gli_time = 'Timestamp'; 63 | 64 | % Time variable column in payload files: 65 | seaexplorer_options.pld_time = 'PLD_REALTIMECLOCK'; 66 | 67 | % Variables to load: 68 | seaexplorer_options.variables = 'all'; 69 | 70 | end 71 | -------------------------------------------------------------------------------- /m/configRTFileOptionsSeaglider.m: -------------------------------------------------------------------------------- 1 | function seaglider_options = configRTFileOptionsSeaglider() 2 | %CONFIGRTFILEOPTIONSSEAGLIDER Configure loading options for Seaglider files in real time. 3 | % 4 | % Syntax: 5 | % SEAGLIDER_OPTIONS = CONFIGRTFILEOPTIONSSEAGLIDER() 6 | % 7 | % Description: 8 | % SEAGLIDER_OPTIONS = CONFIGRTFILEOPTIONSSEAGLIDER() should return a struct 9 | % with the parameters that control which are the deployment files, 10 | % whether they need to be converted, and which files and data should be used 11 | % in real time mode. The returned struct should have the following fields: 12 | % LOG_NAME_PATTERN: string with the name pattern of Seaglider log files 13 | % to be loaded by LOADSEAGLIDERDATA for processing. 14 | % ENG_NAME_PATTERN: string with the name pattern of Seaglider eng files. 15 | % to be loaded by LOADSEAGLIDERDATA for processing. 16 | % LOG_PARAMS: string cell array with the name of the parameters from 17 | % log files to be loaded by LOADSEAGLIDERDATA. Restricting the list of 18 | % parameters to load may reduce the memory footprint. 19 | % ENG_COLUMNS: string cell array with the name of the data columns from 20 | % eng files to be loaded by LOADSEAGLIDERDATA. Restricting the list of 21 | % columns to load may reduce the memory footprint. 22 | % 23 | % Examples: 24 | % seaglider_options = configDTFileOptionsSeaglider() 25 | % 26 | % See also: 27 | % MAIN_GLIDER_DATA_PROCESSING_RT 28 | % LOADSEAGLIDERDATA 29 | % 30 | % Authors: 31 | % Joan Pau Beltran 32 | 33 | % Copyright (C) 2013-2016 34 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 35 | % 36 | % 37 | % This program is free software: you can redistribute it and/or modify 38 | % it under the terms of the GNU General Public License as published by 39 | % the Free Software Foundation, either version 3 of the License, or 40 | % (at your option) any later version. 41 | % 42 | % This program is distributed in the hope that it will be useful, 43 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 44 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 | % GNU General Public License for more details. 46 | % 47 | % You should have received a copy of the GNU General Public License 48 | % along with this program. If not, see . 49 | 50 | narginchk(0, 0); 51 | 52 | % Select dive log files to use. All log files: 53 | seaglider_options.log_name_pattern = '^p\d{3}\d{4}\.log$'; 54 | 55 | % Select dive eng files to use. All eng files: 56 | seaglider_options.eng_name_pattern = '^p\d{3}\d{4}\.eng$'; 57 | 58 | % Log parameters to load. 59 | seaglider_options.log_params = 'all'; 60 | 61 | % Eng parameters to load. 62 | seaglider_options.eng_columns = 'all'; 63 | 64 | end 65 | -------------------------------------------------------------------------------- /m/config_tools/configDBAccess.m: -------------------------------------------------------------------------------- 1 | function db_access = configDBAccess() 2 | %CONFIGDBACCESS Configure data base access parameters for glider processing. 3 | % 4 | % Syntax: 5 | % DB_ACCESS = CONFIGDBACCESS() 6 | % 7 | % Description: 8 | % DB_ACCESS = CONFIGDBACCESS() should return a struct with the access 9 | % parameters for the data base to be used during the glider processing 10 | % as needed by the function GETDEPLOYMENTINFODB. 11 | % 12 | % Notes: 13 | % Edit this file filling in the parameters of your data base. 14 | % Once configured, this file will contain private data, so you should not 15 | % make it public. 16 | % 17 | % Examples: 18 | % db_access = configDBAccess() 19 | % 20 | % See also: 21 | % GETDEPLOYMENTINFODB 22 | % 23 | % Authors: 24 | % Joan Pau Beltran 25 | 26 | % Copyright (C) 2013-2016 27 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 28 | % 29 | % 30 | % This program is free software: you can redistribute it and/or modify 31 | % it under the terms of the GNU General Public License as published by 32 | % the Free Software Foundation, either version 3 of the License, or 33 | % (at your option) any later version. 34 | % 35 | % This program is distributed in the hope that it will be useful, 36 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 37 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 38 | % GNU General Public License for more details. 39 | % 40 | % You should have received a copy of the GNU General Public License 41 | % along with this program. If not, see . 42 | 43 | narginchk(0, 0); 44 | 45 | % When using database, set nodb to false and configure DB settings 46 | db_access.active = 0; 47 | %db_access.server = 'jdbc:postgresql://mydb.myportal.mydomain:5433/my_data_base'; 48 | %db_access.name = 'my_data_base'; 49 | %db_access.user = 'myself'; 50 | %db_access.pass = 'top_secret'; 51 | %db_access.driver = 'org.postgresql.Driver'; 52 | 53 | end 54 | -------------------------------------------------------------------------------- /m/config_tools/configDockservers.m: -------------------------------------------------------------------------------- 1 | function dockservers = configDockservers() 2 | %CONFIGDOCKSERVERS Configure dockserver parameters for glider data processing. 3 | % 4 | % Syntax: 5 | % DOCKSERVERS = CONFIGDOCKSERVERS() 6 | % 7 | % Description: 8 | % DOCKSERVERS = CONFIGDOCKSERVERS() should return a struct array with the 9 | % access parameters for the dockservers containing Slocum glider data, as 10 | % needed by the function GETDOCKSERVERFILES. 11 | % 12 | % Notes: 13 | % Edit this file filling in the parameters of your dockservers. 14 | % Once configured, this file will contain private data, so you should not 15 | % make it public. 16 | % 17 | % Examples: 18 | % dockservers = configDockservers() 19 | % 20 | % See also: 21 | % GETDOCKSERVERFILES 22 | % 23 | % Authors: 24 | % Joan Pau Beltran 25 | 26 | % Copyright (C) 2013-2016 27 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 28 | % 29 | % 30 | % This program is free software: you can redistribute it and/or modify 31 | % it under the terms of the GNU General Public License as published by 32 | % the Free Software Foundation, either version 3 of the License, or 33 | % (at your option) any later version. 34 | % 35 | % This program is distributed in the hope that it will be useful, 36 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 37 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 38 | % GNU General Public License for more details. 39 | % 40 | % You should have received a copy of the GNU General Public License 41 | % along with this program. If not, see . 42 | 43 | narginchk(0, 0); 44 | 45 | dockservers.active = 0; 46 | dockservers.remote_base_dir = '/var/opt/gmc/gliders'; 47 | dockservers.remote_xbd_dir = 'from-glider'; 48 | dockservers.remote_log_dir = 'logs'; 49 | 50 | %dockservers.server(1).url = 'http://mydockserver01.myportal.mydomain'; 51 | %dockservers.server(1).host = '130.206.32.240'; 52 | %dockservers.server(1).user = 'localuser'; 53 | %dockservers.server(1).pass = ''; 54 | dockservers.server(1).conn = @sftp; 55 | 56 | %dockservers.server(2).url = 'http://mydockserver02.myportal.mydomain'; 57 | %dockservers.server(2).user = 'myself'; 58 | dockservers.server(2).conn = @sftp; 59 | 60 | end 61 | -------------------------------------------------------------------------------- /m/config_tools/configPathsLocal.m: -------------------------------------------------------------------------------- 1 | function local_paths = configPathsLocal(glider_toolbox_dir) 2 | %CONFIGDTPATHSLOCAL Config local paths for glider deployment delayed time data and figures. 3 | % 4 | % Syntax: 5 | % LOCAL_PATHS = CONFIGDTPATHSLOCAL() 6 | % 7 | % Description: 8 | % LOCAL_PATHS = CONFIGDTPATHSLOCAL() should return a struct with the path 9 | % patterns for the deployment files involved in the glider processing chain 10 | % in delayed time mode. It should have the following fields: 11 | % BINARY_PATH: path pattern of directory of Slocum binary files (.Xbd). 12 | % CACHE_PATH: path pattern of directory of Slocum cache files (.cac). 13 | % LOG_PATH: path pattern of directory of Slocum surface log files (.log). 14 | % ASCII_PATH: path pattern of directory of converted Slocum text files 15 | % (.dba) or Seglider text files (.log and .eng). 16 | % FIGURE_PATH: path pattern of directory for deployment figures. 17 | % NETCDF_L0: path pattern of NetCDF file for raw data 18 | % (data provided by the glider without any meaningful modification). 19 | % NETCDF_L1: path pattern of NetCDF file for processed trajectory data 20 | % (well referenced data with conversions, corrections and derivations). 21 | % NETCDF_L2: path pattern of NetCDF file for processed grid data 22 | % (processed data interpolated on vertical instantaneous profiles). 23 | % PROCESSING_LOG: path pattern of processing log file. 24 | % These path patterns are converted to true paths through the function 25 | % STRFSTRUCT. 26 | % 27 | % Notes: 28 | % Edit this file filling in the paths to reflect your desired file layout. 29 | % 30 | % Examples: 31 | % local_paths = configDTPathsLocal() 32 | % 33 | % See also: 34 | % MAIN_GLIDER_DATA_PROCESSING_DT 35 | % STRFSTRUCT 36 | % 37 | % Authors: 38 | % Joan Pau Beltran 39 | 40 | % Copyright (C) 2013-2016 41 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 42 | % 43 | % 44 | % This program is free software: you can redistribute it and/or modify 45 | % it under the terms of the GNU General Public License as published by 46 | % the Free Software Foundation, either version 3 of the License, or 47 | % (at your option) any later version. 48 | % 49 | % This program is distributed in the hope that it will be useful, 50 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 51 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 52 | % GNU General Public License for more details. 53 | % 54 | % You should have received a copy of the GNU General Public License 55 | % along with this program. If not, see . 56 | 57 | narginchk(1, 1); 58 | 59 | local_paths.base_dir = fullfile(glider_toolbox_dir, 'glider_data', '${GLIDER_NAME}', '${DEPLOYMENT_START,Tyyyymmdd}'); 60 | local_paths.binary_path = fullfile('binary'); 61 | local_paths.cache_path = fullfile('binary'); 62 | local_paths.log_path = fullfile('log'); 63 | local_paths.ascii_path = fullfile('ascii'); 64 | local_paths.figure_path = fullfile('figures'); 65 | local_paths.netcdf_l0 = fullfile('netcdf', 'dep${GLIDER_DEPLOYMENT_CODE,l}_${GLIDER_NAME,l}_${GLIDER_INSTRUMENT_NAME,l}_L0_${DEPLOYMENT_START,Tyyyy-mm-dd}_data_rt.nc'); 66 | local_paths.netcdf_l1 = fullfile('netcdf', 'dep${GLIDER_DEPLOYMENT_CODE,l}_${GLIDER_NAME,l}_${GLIDER_INSTRUMENT_NAME,l}_L1_${DEPLOYMENT_START,Tyyyy-mm-dd}_data_rt.nc'); 67 | local_paths.netcdf_l2 = fullfile('netcdf', 'dep${GLIDER_DEPLOYMENT_CODE,l}_${GLIDER_NAME,l}_${GLIDER_INSTRUMENT_NAME,l}_L2_${DEPLOYMENT_START,Tyyyy-mm-dd}_data_rt.nc'); 68 | local_paths.processing_log = fullfile('dep${GLIDER_DEPLOYMENT_CODE,l}_${GLIDER_NAME,l}_${GLIDER_INSTRUMENT_NAME,l}_${DEPLOYMENT_START,Tyyyy-mm-dd}_data_rt.log'); 69 | local_paths.config_record = fullfile('dep${GLIDER_DEPLOYMENT_CODE,l}_${GLIDER_NAME,l}_${GLIDER_INSTRUMENT_NAME,l}_${DEPLOYMENT_START,Tyyyy-mm-dd}_data_rt.config'); 70 | 71 | end 72 | -------------------------------------------------------------------------------- /m/config_tools/configPathsPublic.m: -------------------------------------------------------------------------------- 1 | function public_paths = configPathsPublic(glider_toolbox_dir, public_site) 2 | %CONFIGDTPATHSPUBLIC Configure public product and figure paths for glider deployment delayed time data. 3 | % 4 | % Syntax: 5 | % PUBLIC_PATHS = CONFIGPATHSPUBLIC() 6 | % 7 | % Description: 8 | % PUBLIC_PATHS = CONFIGPATHSPUBLIC() should return a struct 9 | % with the path patterns for the public copies of the deployment product 10 | % files generated by the glider processing chain. 11 | % It should have the following fields: 12 | % FIGURE_DIR: path pattern of public directory for deployment figures. 13 | % FIGURE_URL: URL pattern pointing to public directory defined above. 14 | % FIGURE_INCLUDE: optional string cell array with the keys of the figures 15 | % to be copied to the public location. If this fiels is not set, all 16 | % generated figures are copied. 17 | % FIGURE_EXCLUDE: optional string cell array with the keys of the figures 18 | % to exclude from copying to the public location. 19 | % FIGURE_INFO: path pattern of the public JSON file providing the list of 20 | % deployment figures with their description and their URL. 21 | % NETCDF_L0: path pattern of the public NetCDF file for raw data 22 | % (data provided by the glider without any meaningful modification). 23 | % NETCDF_L1: path pattern of the publict NetCDF file for processed 24 | % trajectory data (well referenced data with conversions, corrections, 25 | % and derivations). 26 | % NETCDF_L2: path pattern of the public NetCDF file for gridded data 27 | % (processed data interpolated on vertical instantaneous profiles). 28 | % These path patterns are converted to true paths through the function 29 | % STRFSTRUCT. 30 | % 31 | % Notes: 32 | % Edit this file filling in the paths to reflect your desired file layout. 33 | % 34 | % Examples: 35 | % public_paths = configPathsPublic() 36 | % 37 | % See also: 38 | % MAIN_GLIDER_DATA_PROCESSING_DT 39 | % CONFIGDTPATHSLOCAL 40 | % STRFSTRUCT 41 | % 42 | % Authors: 43 | % Joan Pau Beltran 44 | % 45 | % Copyright (C) 2013-2016 46 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 47 | % 48 | % 49 | % This program is free software: you can redistribute it and/or modify 50 | % it under the terms of the GNU General Public License as published by 51 | % the Free Software Foundation, either version 3 of the License, or 52 | % (at your option) any later version. 53 | % 54 | % This program is distributed in the hope that it will be useful, 55 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 56 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 57 | % GNU General Public License for more details. 58 | % 59 | % You should have received a copy of the GNU General Public License 60 | % along with this program. If not, see . 61 | 62 | narginchk(1, 2); 63 | 64 | public_paths.base_dir = fullfile(glider_toolbox_dir, 'glider_data', 'public', '${GLIDER_NAME}', '${DEPLOYMENT_START,Tyyyymmdd}', 'netcdf'); 65 | public_paths.netcdf_l0 = fullfile('dep${GLIDER_DEPLOYMENT_CODE,l}_${GLIDER_NAME,l}_${GLIDER_INSTRUMENT_NAME,l}_L0_${DEPLOYMENT_START,Tyyyy-mm-dd}_data_rt.nc'); 66 | public_paths.netcdf_l1 = fullfile('dep${GLIDER_DEPLOYMENT_CODE,l}_${GLIDER_NAME,l}_${GLIDER_INSTRUMENT_NAME,l}_L1_${DEPLOYMENT_START,Tyyyy-mm-dd}_data_rt.nc'); 67 | public_paths.netcdf_l2 = fullfile('dep${GLIDER_DEPLOYMENT_CODE,l}_${GLIDER_NAME,l}_${GLIDER_INSTRUMENT_NAME,l}_L2_${DEPLOYMENT_START,Tyyyy-mm-dd}_data_rt.nc'); 68 | 69 | public_paths.figure_dir = fullfile('${GLIDER_NAME}', '${DEPLOYMENT_START,Tyyyymmdd}', 'figures'); 70 | public_paths.figure_info = '${DEPLOYMENT_ID,%d}_figures.json'; 71 | 72 | % Data is not published if base_url is not input 73 | if isstruct(public_site) && ~isempty(fieldnames(public_site)) 74 | public_paths.base_url = public_site.base_url; 75 | public_paths.base_html_dir = public_site.base_html_dir; 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /m/config_tools/configWRCPrograms.m: -------------------------------------------------------------------------------- 1 | function wrcprogs = configWRCPrograms(glider_toolbox_dir) 2 | % CONFIGWRCPROGRAMS Configure path of the Slocum glider programs provided by WRC. 3 | % 4 | % Syntax: 5 | % WRCPROGS = CONFIGWRCPROGRAMS() 6 | % 7 | % Description: 8 | % WRCPROGS = CONFIGWRCPROGRAMS() should return a struct with the path to 9 | % the executables provided by the Webb Research Company to deal with Slocum 10 | % glider data files. This function replaces the configWRCPrograms and 11 | % assumes that the external libraries are installed under the 12 | % GLIDER_TOOLBOX_DIR/ext_lib/bin. Contrary as in previous versions, this 13 | % function must not be edited. Users must use the configuration files to 14 | % overwrite the values returned by CONFIGWRCPROGRAMS if their external 15 | % libraries live in a different path. Read SETUPCONFIGURATION for more 16 | % details. 17 | % 18 | % Users can use gtb_install_extlib to install the WRC programs in the 19 | % default path used by this function. 20 | % Notes: 21 | % The executables required are provided by the Webb Research Company and 22 | % should be available in your system binary path as required by the 23 | % XBD2DBA function. 24 | % 25 | % Examples: 26 | % wrcprogs = configWRCPrograms() 27 | % 28 | % See also: 29 | % XBD2DBA 30 | % 31 | % Authors: 32 | % Joan Pau Beltran 33 | 34 | % Copyright (C) 2013-2016 35 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 36 | % 37 | % 38 | % This program is free software: you can redistribute it and/or modify 39 | % it under the terms of the GNU General Public License as published by 40 | % the Free Software Foundation, either version 3 of the License, or 41 | % (at your option) any later version. 42 | % 43 | % This program is distributed in the hope that it will be useful, 44 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 45 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 46 | % GNU General Public License for more details. 47 | % 48 | % You should have received a copy of the GNU General Public License 49 | % along with this program. If not, see . 50 | 51 | narginchk(1, 1); 52 | 53 | wrcprogs.base_dir = fullfile(glider_toolbox_dir, 'ext_lib', 'bin'); 54 | % This program is needed. 55 | wrcprogs.dbd2asc = fullfile('dbd2asc'); 56 | % These programs are optional. 57 | wrcprogs.dba_merge = fullfile('dba_merge'); 58 | wrcprogs.dba_sensor_filter = fullfile('dba_sensor_filter'); 59 | wrcprogs.dba_time_filter = fullfile('dba_time_filter'); 60 | wrcprogs.dba2_orig_matlab = fullfile('dba2_orig_matlab'); 61 | wrcprogs.rename_dbd_files = fullfile('rename_dbd_files'); 62 | 63 | end 64 | -------------------------------------------------------------------------------- /m/config_tools/createFStruct.m: -------------------------------------------------------------------------------- 1 | function [ data_paths ] = createFStruct( path_formats, deployment ) 2 | % CREATEFSTRUCT Produces a structure with the path tree for glider 3 | % data processing for the specific deployment 4 | % 5 | % Syntax: 6 | % [DATA_PATHS] = CREATEFSTRUCT(PATH_FORMATS, DEPLOYMENT) 7 | % 8 | % Description: 9 | % CREATEFSTRUCT creates the directory names for glider data for a given 10 | % format specified in path_formats and the information of the deployment. 11 | % path_formats may contain any field. 12 | % - 13 | % This function calls STRFSTRUCT to complete the name of the files and 14 | % directories using the format defined by the function. For example, 15 | % ${GLIDER_NAME} may be used to complete the string with the glider name 16 | % or ${DEPLOYMENT_START,Tyyyymmdd} to use start date of the deployment 17 | % in the path name. Refer to STRFSTRUCT for more details of the name 18 | % formats. 19 | % 20 | % Input: 21 | % PATH_FORMATS is a structure that contains the fields described above. 22 | % The required fields are base_dir, binary_path, ascii_path, 23 | % cache_path and log_path. The reference to figure_path and netCDF 24 | % file names is optional and the names in the output to these 25 | % products will be omitted if the input does not contain them. 26 | % 27 | % Output: 28 | % DATA_PATHS is a structure of directory and names containing the 29 | % information of the paths built from the input path_formats.% 30 | % 31 | % Authors: 32 | % Miguel Charcos Llorens 33 | % 34 | % Copyright (C) 2013-2016 35 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 36 | % 37 | % 38 | % This program is free software: you can redistribute it and/or modify 39 | % it under the terms of the GNU General Public License as published by 40 | % the Free Software Foundation, either version 3 of the License, or 41 | % (at your option) any later version. 42 | % 43 | % This program is distributed in the hope that it will be useful, 44 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 45 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 46 | % GNU General Public License for more details. 47 | % 48 | % You should have received a copy of the GNU General Public License 49 | % along with this program. If not, see . 50 | % 51 | 52 | narginchk(2, 2); 53 | 54 | path_list = fieldnames(path_formats); 55 | data_paths = struct(); 56 | 57 | for i=1:numel(path_list) 58 | current_path_name = path_list(i); 59 | data_paths.(current_path_name{1}) = ... 60 | fullfile(strfstruct(path_formats.(current_path_name{1}), deployment)); 61 | end 62 | end 63 | 64 | -------------------------------------------------------------------------------- /m/config_tools/extractDeploymentConfig.m: -------------------------------------------------------------------------------- 1 | function [ glider_type, processing_config ] = extractDeploymentConfig( glider_model, config ) 2 | % EXTRACTDEPLOYMENTCONFIGURATION Selects the configuration values for the 3 | % specific glider model 4 | % 5 | % Syntax: 6 | % [GLIDER_TYPE, PROCESSING_CONFIG] = ... 7 | % EXTRACTDEPLOYMENTCONFIGURATION(GLIDER_MODEL, CONFIG) 8 | % 9 | % Description: 10 | % EXTRACTDEPLOYMENTCONFIGURATION selects the file definition and 11 | % processing configurations for a specific glider model given a 12 | % configuration structure that contains the configuration for all 13 | % "possible" glider models. It returns the glider type that is based on 14 | % the name conventions as follow: 15 | % glider_model glider_type 16 | % .*slocum.*g1.* ==> slocum_g1 17 | % .*slocum.*g2.* ==> slocum_g2 18 | % .*seaglider.* ==> seaglider 19 | % .*seaexplorer.* ==> seaexplorer 20 | % 21 | % Input: 22 | % GLIDER_MODEL defines the name of the glider model. 23 | % 24 | % CONFIG is the structure containing the configuration of the processing 25 | % as defined by SETUPCONFIGURATION. 26 | % 27 | % Output: 28 | % GLIDER_TYPE is the glider type as explained in the description above. 29 | % 30 | % PROCESSING_CONFIG is the structure containing the configuration for 31 | % the specified glider model. It contains the following fields with 32 | % structures for each type of configuration: 33 | % - file_options 34 | % - preprocessing_options 35 | % - processing_options 36 | % - netcdf_l0_options 37 | % - gridding_options 38 | % - netcdf_l1_options 39 | % - netcdf_egol1_options 40 | % - netcdf_l2_options 41 | % - figproc_options 42 | % - figgrid_options 43 | % 44 | % Authors: 45 | % Miguel Charcos Llorens 46 | % 47 | % Copyright (C) 2013-2016 48 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 49 | % 50 | % 51 | % This program is free software: you can redistribute it and/or modify 52 | % it under the terms of the GNU General Public License as published by 53 | % the Free Software Foundation, either version 3 of the License, or 54 | % (at your option) any later version. 55 | % 56 | % This program is distributed in the hope that it will be useful, 57 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 58 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 59 | % GNU General Public License for more details. 60 | % 61 | % You should have received a copy of the GNU General Public License 62 | % along with this program. If not, see . 63 | 64 | 65 | narginchk(2, 2); 66 | 67 | glider_type = ''; 68 | if ~isempty(regexpi(glider_model, '.*slocum.*g1.*', 'match', 'once')) 69 | glider_type = 'slocum_g1'; 70 | elseif ~isempty(regexpi(glider_model, '.*slocum.*g2.*', 'match', 'once')) 71 | glider_type = 'slocum_g2'; 72 | elseif ~isempty(regexpi(glider_model, '.*seaglider.*', 'match', 'once')) 73 | glider_type = 'seaglider'; 74 | elseif ~isempty(regexpi(glider_model, '.*seaexplorer.*', 'match', 'once')) 75 | glider_type = 'seaexplorer'; 76 | end 77 | 78 | % Options depending on the type of glider: 79 | switch glider_type 80 | case 'slocum_g1' 81 | processing_config.file_options = config.file_options_slocum; 82 | processing_config.preprocessing_options = config.preprocessing_options_slocum; 83 | processing_config.processing_options = config.processing_options_slocum_g1; 84 | processing_config.netcdf_l0_options = config.output_netcdf_l0_slocum; 85 | processing_config.netcdf_eng_options = config.output_netcdf_eng_slocum; 86 | case 'slocum_g2' 87 | processing_config.file_options = config.file_options_slocum; 88 | processing_config.preprocessing_options = config.preprocessing_options_slocum; 89 | processing_config.processing_options = config.processing_options_slocum_g2; 90 | processing_config.netcdf_l0_options = config.output_netcdf_l0_slocum; 91 | processing_config.netcdf_eng_options = config.output_netcdf_eng_slocum; 92 | case 'seaglider' 93 | processing_config.file_options = config.file_options_seaglider; 94 | processing_config.preprocessing_options = config.preprocessing_options_seaglider; 95 | processing_config.processing_options = config.processing_options_seaglider; 96 | processing_config.netcdf_eng_options = config.output_netcdf_eng_seaglider; 97 | case 'seaexplorer' 98 | processing_config.file_options = config.file_options_seaexplorer; 99 | processing_config.preprocessing_options = config.preprocessing_options_seaexplorer; 100 | processing_config.processing_options = config.processing_options_seaexplorer; 101 | processing_config.netcdf_l0_options = config.output_netcdf_l0_seaexplorer; 102 | processing_config.netcdf_eng_options = config.output_netcdf_eng_seaexplorer; 103 | end 104 | 105 | processing_config.gridding_options = config.gridding_options; 106 | processing_config.netcdf_l1_options = config.output_netcdf_l1; 107 | processing_config.netcdf_egol1_options = config.output_netcdf_egol1; 108 | processing_config.netcdf_l2_options = config.output_netcdf_l2; 109 | processing_config.figproc_options = config.figures_processed.options; 110 | processing_config.figgrid_options = config.figures_gridded.options; 111 | 112 | end 113 | 114 | -------------------------------------------------------------------------------- /m/mex_tools/poly2tri.m: -------------------------------------------------------------------------------- 1 | function [xtri, ytri] = poly2tri(x, y) 2 | %POLY2TRI Polygon triangulation using GPC library. 3 | % 4 | % Syntax: 5 | % [XTRI, YTRI] = POLY2TRI(X, Y) 6 | % 7 | % Description: 8 | % [XTRI, YTRI] = POLY2TRI(X, Y) triangulates the polygon with coordinates in 9 | % vectors X and Y, returning the coordinates of the resulting triangulation 10 | % 3-by-M arrays XTRI and YTRI, where M is the number of triangles in the 11 | % decomposition, and each column defines a triangle. X and Y must b the same 12 | % size. The polygon may be self-intersecting, and it is supposed to be 13 | % closed even if the first vertex is not repeated at the end. 14 | % 15 | % Notes: 16 | % The true decomposition is performed by the function GPC_POLYGON_TO_TRISTRIP 17 | % of the General Polygon Clipper library (GPC), written by Alan Murta. 18 | % This function is called in the companion mex file. 19 | % 20 | % An alternative implementation using constrained Delaunay triangulation 21 | % functions provided by MATLAB is commented in this source file. 22 | % If you can not build or use the GPC based mex file, uncoment those lines. 23 | % 24 | % Examples: 25 | % x = [0 -1 -1 0 0 1 1 0] 26 | % y = [0 0 -1 -1 1 1 0 0] 27 | % [xtri, ytri] = poly2tri(x, y) 28 | % patch(xtri, ytri, 1:size(xtri,2), 'Marker', 'none', 'EdgeColor', 'none') 29 | % hold on 30 | % plot(x, y, '-r', 'LineWidth', 2) 31 | % 32 | % References: 33 | % Alan Murta, GPC - General Polygon Clipper library: 34 | % 35 | % 36 | % Authors: 37 | % Joan Pau Beltran 38 | 39 | % Copyright (C) 2013-2016 40 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 41 | % 42 | % 43 | % This program is free software: you can redistribute it and/or modify 44 | % it under the terms of the GNU General Public License as published by 45 | % the Free Software Foundation, either version 3 of the License, or 46 | % (at your option) any later version. 47 | % 48 | % This program is distributed in the hope that it will be useful, 49 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 50 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 51 | % GNU General Public License for more details. 52 | % 53 | % You should have received a copy of the GNU General Public License 54 | % along with this program. If not, see . 55 | 56 | error('glider_toolbox:poly2tri:MissingMexfile', 'Missing required mex file.'); 57 | 58 | % Altrernative implementation using Delaunay Triangulation built in MATLAB. 59 | %{ 60 | nv = numel(x); 61 | triangulation = DelaunayTri(x(:), y(:), [1 (2:nv); (2:nv) 1]'); 62 | indices = triangulation.inOutStatus; 63 | faces = triangulation.Triangulation(indices, :); 64 | vertices = triangulation.X; 65 | xtri = reshape(vertices(faces, 1), size(faces))'; 66 | ytri = reshape(vertices(faces, 2), size(faces))'; 67 | %} 68 | 69 | end 70 | -------------------------------------------------------------------------------- /m/mex_tools/posixtime.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief MATLAB interface to get POSIX time using standard C time functions. 4 | * @author Joan Pau Beltran 5 | * 6 | * Copyright (C) 2013-2016 7 | * ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears. 8 | * 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program. If not, see . 22 | * 23 | * This file implements a method to get the current system POSIX time in MATLAB, 24 | * assuming a POSIX compilant version of the standard C libraries. 25 | * 26 | * The corresponding mex file may be built with the command: 27 | * mex posixtime.c 28 | */ 29 | 30 | 31 | #include "mex.h" 32 | #include "time.h" 33 | 34 | 35 | void mexFunction( int nlhs, mxArray *plhs[], 36 | int nrhs, const mxArray *prhs[] ) 37 | { 38 | time_t t; 39 | 40 | /* Check for proper number of arguments. */ 41 | if (nrhs!=0) 42 | mexErrMsgTxt("Zero inputs required."); 43 | if (nlhs>1) 44 | mexErrMsgTxt("Too many output arguments."); 45 | 46 | /* Get current POSIX time. */ 47 | time(&t); 48 | 49 | /* Assign pointers to corresponding outputs. */ 50 | plhs[0] = mxCreateDoubleScalar((double) t); 51 | } 52 | 53 | -------------------------------------------------------------------------------- /m/mex_tools/posixtime.m: -------------------------------------------------------------------------------- 1 | function t = posixtime() 2 | %POSIXTIME Current POSIX time using low level utilities. 3 | % 4 | % Syntax: 5 | % T = POSIXTIME() 6 | % 7 | % Description: 8 | % T = POSIXTIME() returns the current POSIX time: the number of seconds since 9 | % 1970-01-01 00:00:00 UTC, not counting the effects of leap seconds. 10 | % 11 | % Notes: 12 | % This function provides a compatibility interface for MATLAB and Octave, 13 | % computing the POSIX time using lower level tools available in each system: 14 | % In Octave, through the built-in interface to the ANSI C function TIME. 15 | % In MATLAB, through a mex file interface to the ANSI C function TIME. 16 | % 17 | % Examples: 18 | % t = posixtime() 19 | % datestr(posixtime2utc(t)) 20 | % datestr(now()) 21 | % 22 | % See also: 23 | % POSIXTIME2UTC 24 | % UTC2POSIXTIME 25 | % 26 | % Authors: 27 | % Joan Pau Beltran 28 | 29 | % Copyright (C) 2013-2016 30 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 31 | % 32 | % 33 | % This program is free software: you can redistribute it and/or modify 34 | % it under the terms of the GNU General Public License as published by 35 | % the Free Software Foundation, either version 3 of the License, or 36 | % (at your option) any later version. 37 | % 38 | % This program is distributed in the hope that it will be useful, 39 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 40 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 41 | % GNU General Public License for more details. 42 | % 43 | % You should have received a copy of the GNU General Public License 44 | % along with this program. If not, see . 45 | 46 | narginchk(0, 0); 47 | 48 | % Consider making the variable persistent 49 | % (the needed emptiness check may be more expensive than the existence check). 50 | ISOCTAVE = exist('OCTAVE_VERSION','builtin'); 51 | 52 | if ISOCTAVE 53 | t = time(); 54 | else 55 | error('glider_toolbox:posixtime:MissingMexFile', ... 56 | 'Missing required mex file.'); 57 | end 58 | 59 | end 60 | -------------------------------------------------------------------------------- /m/modules/module_figures.m: -------------------------------------------------------------------------------- 1 | function [ figures ] = module_figures(netcdf_lX_file, figure_dir, varargin) 2 | % MODULE_FIGURES Create figures from L1 or L2 level 3 | % 4 | % 5 | % Authors: 6 | % Miguel Charcos Llorens 7 | % 8 | % Copyright (C) 2013-2016 9 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 10 | % 11 | % 12 | % This program is free software: you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation, either version 3 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You should have received a copy of the GNU General Public License 23 | % along with this program. If not, see . 24 | 25 | narginchk(2, 6); 26 | 27 | options.figure_type = 'processed'; 28 | options.configuration = ''; 29 | 30 | %% Parse optional arguments. 31 | % Get option key-value pairs in any accepted call signature. 32 | argopts = varargin; 33 | if isscalar(argopts) && isstruct(argopts{1}) 34 | % Options passed as a single option struct argument: 35 | % field names are option keys and field values are option values. 36 | opt_key_list = fieldnames(argopts{1}); 37 | opt_val_list = struct2cell(argopts{1}); 38 | elseif mod(numel(argopts), 2) == 0 39 | % Options passed as key-value argument pairs. 40 | opt_key_list = argopts(1:2:end); 41 | opt_val_list = argopts(2:2:end); 42 | else 43 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 44 | 'Invalid optional arguments (neither key-value pairs nor struct).'); 45 | end 46 | % Overwrite default options with values given in extra arguments. 47 | for opt_idx = 1:numel(opt_key_list) 48 | opt = lower(opt_key_list{opt_idx}); 49 | val = opt_val_list{opt_idx}; 50 | if isfield(options, opt) 51 | options.(opt) = val; 52 | else 53 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 54 | 'Invalid option: %s.', opt); 55 | end 56 | end 57 | 58 | %% Read configuration values from configuration file 59 | if ischar(options.configuration) 60 | glider_toolbox_dir = configGliderToolboxPath(); 61 | % The processing mode does not matter for the figure configuration so 62 | % we can take the default one of setupConfiguration 63 | config = setupConfiguration(glider_toolbox_dir, 'fconfig', options.configuration); 64 | else 65 | config = options.configuration; 66 | end 67 | 68 | if isempty(config) && ~isstruct(config) 69 | error(strcat('glider_toolbox:', mfilename, ':MissingConfiguration'),... 70 | 'Empty configuration file'); 71 | end 72 | 73 | % Data and meta data at each step & the ones that are returned according 74 | % to the data_result option 75 | data_processed = struct(); 76 | figures = ''; 77 | 78 | %% Load data from L1 or L2 file. 79 | try 80 | [ ~, data_processed, ~, ~, deployment ] = loadNetCDF( netcdf_lX_file ); 81 | catch exception 82 | error(strcat('glider_toolbox:', mfilename, ':ProcessError'), ... 83 | 'Error loading data from %s: %s', netcdf_l1_file, getReport(exception, 'extended')); 84 | end 85 | 86 | if ~isfield(deployment, 'processing_level') 87 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 88 | 'Could not recognize level from processing_level attribute.'); 89 | end 90 | 91 | if strfind(deployment.processing_level, 'L1') 92 | disp('Creating figures for level 1 product'); 93 | figure_config = config.figures_processed.options; 94 | elseif strfind(deployment.processing_level, 'L2') 95 | disp('Creating figures for level 2 product'); 96 | figure_config = config.figures_gridded.options; 97 | else 98 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 99 | 'Invalid netCDF level: %s.', deployment.processing_level); 100 | end 101 | 102 | %% Generate gridded data figures. 103 | if ~isempty(fieldnames(data_processed)) && ~isempty(figure_dir) 104 | disp(strcat('Generating figures from', {' '}, options.figure_type, {' '} ,'data...')); 105 | try 106 | figures = generateGliderFigures( ... 107 | data_processed, figure_config, ... 108 | 'date', datestr(posixtime2utc(posixtime()), 'yyyy-mm-ddTHH:MM:SS+00:00'), ... 109 | 'dirname', figure_dir); 110 | catch exception 111 | disp('Error generating gridded data figures:'); 112 | disp(getReport(exception, 'extended')); 113 | end 114 | end 115 | 116 | end -------------------------------------------------------------------------------- /m/modules/module_figures.m~: -------------------------------------------------------------------------------- 1 | function [figures, meta_processed, data_processed] = module_figures(netcdf_lX_file, figure_dir, varargin) 2 | % MODULE_FIGURES Create figures from L1 or L2 level 3 | % 4 | % 5 | % Authors: 6 | % Miguel Charcos Llorens 7 | % 8 | % Copyright (C) 2013-2016 9 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 10 | % 11 | % 12 | % This program is free software: you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation, either version 3 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You should have received a copy of the GNU General Public License 23 | % along with this program. If not, see . 24 | 25 | narginchk(2, 6); 26 | 27 | options.figure_type = 'processed'; 28 | options.configuration = ''; 29 | 30 | %% Parse optional arguments. 31 | % Get option key-value pairs in any accepted call signature. 32 | argopts = varargin; 33 | if isscalar(argopts) && isstruct(argopts{1}) 34 | % Options passed as a single option struct argument: 35 | % field names are option keys and field values are option values. 36 | opt_key_list = fieldnames(argopts{1}); 37 | opt_val_list = struct2cell(argopts{1}); 38 | elseif mod(numel(argopts), 2) == 0 39 | % Options passed as key-value argument pairs. 40 | opt_key_list = argopts(1:2:end); 41 | opt_val_list = argopts(2:2:end); 42 | else 43 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 44 | 'Invalid optional arguments (neither key-value pairs nor struct).'); 45 | end 46 | % Overwrite default options with values given in extra arguments. 47 | for opt_idx = 1:numel(opt_key_list) 48 | opt = lower(opt_key_list{opt_idx}); 49 | val = opt_val_list{opt_idx}; 50 | if isfield(options, opt) 51 | options.(opt) = val; 52 | else 53 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 54 | 'Invalid option: %s.', opt); 55 | end 56 | end 57 | 58 | %% Read configuration values from configuration file 59 | if ischar(options.configuration) 60 | glider_toolbox_dir = configGliderToolboxPath(); 61 | % The processing mode does not matter for the figure configuration so 62 | % we can take the default one of setupConfiguration 63 | config = setupConfiguration(glider_toolbox_dir, 'fconfig', options.configuration); 64 | else 65 | config = options.configuration; 66 | end 67 | 68 | if isempty(config) && ~isstruct(config) 69 | error(strcat('glider_toolbox:', mfilename, ':MissingConfiguration'),... 70 | 'Empty configuration file'); 71 | end 72 | 73 | % Data and meta data at each step & the ones that are returned according 74 | % to the data_result option 75 | data_processed = struct(); 76 | figures = ''; 77 | 78 | %% Load data from L1 or L2 file. 79 | try 80 | [ meta_processed, data_processed, ~, atts_processed, deployment ] = loadNetCDF( netcdf_lX_file ); 81 | catch exception 82 | error(strcat('glider_toolbox:', mfilename, ':ProcessError'), ... 83 | 'Error loading data from %s: %s', netcdf_l1_file, getReport(exception, 'extended')); 84 | end 85 | 86 | if ~isfield(deployment, 'processing_level') 87 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 88 | 'Invalid figure option: %s.', options.figure_type); 89 | end 90 | 91 | if strcmp(deployment.processing_level, 'processed') 92 | figure_config = config.figures_processed.options; 93 | elseif strcmp(options.figure_type, 'gridded') 94 | figure_config = config.figures_gridded.options; 95 | else 96 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 97 | 'Invalid figure option: %s.', options.figure_type); 98 | end 99 | 100 | %% Generate gridded data figures. 101 | if ~isempty(fieldnames(data_processed)) && ~isempty(figure_dir) 102 | disp(strcat('Generating figures from', {' '}, options.figure_type, {' '} ,'data...')); 103 | try 104 | figures = generateGliderFigures( ... 105 | data_processed, figure_config, ... 106 | 'date', datestr(posixtime2utc(posixtime()), 'yyyy-mm-ddTHH:MM:SS+00:00'), ... 107 | 'dirname', figure_dir); 108 | catch exception 109 | disp('Error generating gridded data figures:'); 110 | disp(getReport(exception, 'extended')); 111 | end 112 | end 113 | 114 | end -------------------------------------------------------------------------------- /m/modules/module_l1_to_l2.m: -------------------------------------------------------------------------------- 1 | function [outputs, meta_gridded, data_gridded] = module_l1_to_l2(netcdf_l1_file, netcdf_l2_file, varargin) 2 | % MODULE_L1_TO_L2 Process glider data from L1 to L2 level 3 | % 4 | % 5 | % Authors: 6 | % Miguel Charcos Llorens 7 | % 8 | % Copyright (C) 2013-2016 9 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 10 | % 11 | % 12 | % This program is free software: you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation, either version 3 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You should have received a copy of the GNU General Public License 23 | % along with this program. If not, see . 24 | 25 | narginchk(2, 6); 26 | 27 | options.processing_mode = 'rt'; 28 | options.configuration = ''; 29 | 30 | %% Parse optional arguments. 31 | % Get option key-value pairs in any accepted call signature. 32 | argopts = varargin; 33 | if isscalar(argopts) && isstruct(argopts{1}) 34 | % Options passed as a single option struct argument: 35 | % field names are option keys and field values are option values. 36 | opt_key_list = fieldnames(argopts{1}); 37 | opt_val_list = struct2cell(argopts{1}); 38 | elseif mod(numel(argopts), 2) == 0 39 | % Options passed as key-value argument pairs. 40 | opt_key_list = argopts(1:2:end); 41 | opt_val_list = argopts(2:2:end); 42 | else 43 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 44 | 'Invalid optional arguments (neither key-value pairs nor struct).'); 45 | end 46 | % Overwrite default options with values given in extra arguments. 47 | for opt_idx = 1:numel(opt_key_list) 48 | opt = lower(opt_key_list{opt_idx}); 49 | val = opt_val_list{opt_idx}; 50 | if isfield(options, opt) 51 | options.(opt) = val; 52 | else 53 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 54 | 'Invalid option: %s.', opt); 55 | end 56 | end 57 | 58 | %% Read configuration values from configuration file 59 | if ischar(options.configuration) 60 | glider_toolbox_dir = configGliderToolboxPath(); 61 | config = setupConfiguration(glider_toolbox_dir, ... 62 | 'processing_mode', options.processing_mode, ... 63 | 'fconfig', options.configuration); 64 | else 65 | config = options.configuration; 66 | end 67 | 68 | if isempty(config) && ~isstruct(config) 69 | error(strcat('glider_toolbox:', mfilename, ':MissingConfiguration'),... 70 | 'Empty configuration file'); 71 | end 72 | 73 | % Data and meta data at each step & the ones that are returned according 74 | % to the data_result option 75 | meta_processed = struct(); 76 | data_processed = struct(); 77 | meta_gridded = struct(); 78 | data_gridded = struct(); 79 | outputs = struct(); 80 | 81 | %% Load data from L1 file. 82 | try 83 | [ meta_processed, data_processed, ~, atts_processed ] = loadNetCDF( netcdf_l1_file ); 84 | catch exception 85 | error(strcat('glider_toolbox:', mfilename, ':ProcessError'), ... 86 | 'Error loading data from %s: %s', netcdf_l1_file, getReport(exception, 'extended')); 87 | end 88 | 89 | %% Grid processed glider data. 90 | if ~isempty(fieldnames(data_processed)) 91 | disp('Gridding glider data...'); 92 | try 93 | [data_gridded, meta_gridded] = ... 94 | gridGliderData(data_processed, meta_processed, config.gridding_options); 95 | catch exception 96 | error(strcat('glider_toolbox:', mfilename, ':ProcessError'), ... 97 | 'Error gridding glider deployment data: %s', getReport(exception, 'extended')); 98 | end 99 | end 100 | 101 | %% Generate L2 (gridded data) netcdf file, if needed and possible. 102 | if ~isempty(fieldnames(data_gridded)) && ~isempty(netcdf_l2_file) 103 | netcdf_l2_options = config.output_netcdf_l2; 104 | % reformat attributes 105 | for i = 1:length(netcdf_l2_options.attributes) 106 | if ~isempty(netcdf_l2_options.attributes(i).value) 107 | varname = netcdf_l2_options.attributes(i).name; 108 | atts_gridded.(varname) = netcdf_l2_options.attributes(i).value; 109 | end 110 | end 111 | disp('Generating NetCDF L2 output...'); 112 | try 113 | outputs.netcdf_l2 = generateOutputNetCDF( ... 114 | netcdf_l2_file, data_gridded, meta_gridded, atts_gridded, ... 115 | netcdf_l2_options.variables, ... 116 | netcdf_l2_options.dimensions, ... 117 | atts_processed); 118 | disp(['Output NetCDF L2 (gridded data) generated: ' ... 119 | outputs.netcdf_l2 '.']); 120 | catch exception 121 | disp(['Error generating NetCDF L2 (gridded data) output ' ... 122 | netcdf_l2_file ':']); 123 | disp(getReport(exception, 'extended')); 124 | end 125 | elseif isempty(netcdf_l2_file) 126 | disp('Skip generation of NetCDF L2 outputs'); 127 | end 128 | 129 | end -------------------------------------------------------------------------------- /m/netcdf_tools/convert2NetCDFEGO.m: -------------------------------------------------------------------------------- 1 | function [ convert_data, convert_meta ] = convert2NetCDFEGO( variable_data, variable_meta ) 2 | % TODO: Add description convert2NetCDFEGO 3 | 4 | narginchk(2, 2); 5 | 6 | convert_data = variable_data; 7 | convert_meta = variable_meta; 8 | 9 | % Make all attributes uppercase 10 | meta_var_name_list = fieldnames(convert_meta); 11 | for var_name_idx = 1:numel(meta_var_name_list) 12 | var_name = meta_var_name_list{var_name_idx}; 13 | new_var_name = upper(var_name); 14 | [convert_meta(:).(new_var_name)] = deal(convert_meta(:).(var_name)); 15 | convert_meta = rmfield(convert_meta,var_name); 16 | end 17 | 18 | 19 | % Make all data uppercase and convert values to have STRINGXX dims 20 | data_var_name_list = fieldnames(convert_data); 21 | for var_name_idx = 1:numel(data_var_name_list) 22 | var_name = data_var_name_list{var_name_idx}; 23 | new_var_name = upper(var_name); 24 | [convert_data(:).(new_var_name)] = deal(convert_data(:).(var_name)); 25 | convert_data = rmfield(convert_data,var_name); 26 | 27 | % Truncate values for STRINGXX dimensions 28 | if isfield(convert_meta, new_var_name) 29 | if isfield(convert_meta(:).(new_var_name),'dimensions') 30 | % Browse dimensions looking for STRINGXX 31 | for k=1:length(convert_meta.(new_var_name).dimensions) 32 | % Check if dimension is of type STRINGXX 33 | if strfind(convert_meta.(new_var_name).dimensions{k}, 'STRING') 34 | % Extract XX dimension from name 35 | dim_bytes = str2num(strrep(convert_meta.(new_var_name).dimensions{k}, 'STRING','')); 36 | 37 | % Truncate string to the maximum allowed if larger 38 | % than dimension specifications 39 | if length(convert_data.(new_var_name)) > dim_bytes 40 | convert_data.(new_var_name) = convert_data.(new_var_name)(1:dim_bytes); 41 | end 42 | end 43 | end 44 | end 45 | end 46 | end 47 | 48 | end 49 | 50 | -------------------------------------------------------------------------------- /m/netcdf_tools/loadNetCDF.m: -------------------------------------------------------------------------------- 1 | function [ meta, data, dims, atts, deployment ] = loadNetCDF( filename, varargin ) 2 | %GETNCVARS Reads data from NC file 3 | % 4 | % Syntax: 5 | % [ META, DATA, DIMS, ATTS ] = LOADNETCDF( FILENAME ); 6 | % 7 | % Description: 8 | % Reads the netCDF file and returns a structure containing the data. 9 | % The fields of the structure correspond to the names of the data. The 10 | % values of the structures are the values for each specific variable. 11 | % 12 | % Authors: 13 | % Miguel Charcos Llorens 14 | 15 | % Copyright (C) 2013-2016 16 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 17 | % 18 | % 19 | % This program is free software: you can redistribute it and/or modify 20 | % it under the terms of the GNU General Public License as published by 21 | % the Free Software Foundation, either version 3 of the License, or 22 | % (at your option) any later version. 23 | % 24 | % This program is distributed in the hope that it will be useful, 25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | % GNU General Public License for more details. 28 | % 29 | % You should have received a copy of the GNU General Public License 30 | % along with this program. If not, see . 31 | 32 | narginchk(1, 3); 33 | options.dictionary = ''; 34 | 35 | %% Parse optional arguments. 36 | % Get option key-value pairs in any accepted call signature. 37 | argopts = varargin; 38 | if isscalar(argopts) && isstruct(argopts{1}) 39 | % Options passed as a single option struct argument: 40 | % field names are option keys and field values are option values. 41 | opt_key_list = fieldnames(argopts{1}); 42 | opt_val_list = struct2cell(argopts{1}); 43 | elseif mod(numel(argopts), 2) == 0 44 | % Options passed as key-value argument pairs. 45 | opt_key_list = argopts(1:2:end); 46 | opt_val_list = argopts(2:2:end); 47 | else 48 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 49 | 'Invalid optional arguments (neither key-value pairs nor struct).'); 50 | end 51 | % Overwrite default options with values given in extra arguments. 52 | for opt_idx = 1:numel(opt_key_list) 53 | opt = lower(opt_key_list{opt_idx}); 54 | val = opt_val_list{opt_idx}; 55 | if isfield(options, opt) 56 | options.(opt) = val; 57 | else 58 | error(strcat('glider_toolbox:', mfilename, ':InvalidOptions'), ... 59 | 'Invalid option: %s.', opt); 60 | end 61 | end 62 | 63 | % TODO: Check against XML dictionary 64 | 65 | % Read NC file 66 | fileContent = nc_info(filename); 67 | 68 | %% Run through the list of global attributes 69 | disp('Reading global attributes...'); 70 | natts = length(fileContent.Attribute); 71 | atts = []; 72 | deployment = struct(); 73 | for attIdx = 1:natts 74 | varname = fileContent.Attribute(attIdx).Name; 75 | deployment.(varname) = fileContent.Attribute(attIdx).Value; 76 | 77 | atts(end+1).name = fileContent.Attribute(attIdx).Name; 78 | atts(end).value = fileContent.Attribute(attIdx).Value; 79 | %matlabCommand = ['atts.', attName, ' = ncreadatt(filename, ''/'', ''', attName, ''');']; 80 | %eval(matlabCommand); 81 | end 82 | 83 | %% Run through the list of dimensions 84 | disp('Reading dimensions...'); 85 | ndims = length(fileContent.Dimension); 86 | dims = []; 87 | for dimIdx = 1:ndims 88 | dims(end+1).name = fileContent.Dimension(dimIdx).Name; 89 | if fileContent.Dimension(dimIdx).Unlimited 90 | dims(end).length = 0; 91 | else 92 | dims(end).length = fileContent.Dimension(dimIdx).Length; 93 | end 94 | end 95 | 96 | %% Run through the list of available variables 97 | disp('Reading variables...'); 98 | ndata = length(fileContent.Dataset); 99 | data = struct(); 100 | meta = struct(); 101 | for varIdx = 1:ndata 102 | % Get the variable name 103 | varName = fileContent.Dataset(varIdx).Name; 104 | % Build a command to load that variable 105 | matlabCommand = ['data.', varName, ' = nc_varget(filename, ''', varName, ''');']; 106 | % Evaluate the command 107 | eval(matlabCommand); 108 | %disp( varName); 109 | 110 | % get attributes for this variable 111 | meta.(varName).dimensions = fileContent.Dataset(varIdx).Dimension; 112 | att_array = fileContent.Dataset.Attribute; 113 | natts = length(att_array); 114 | meta.(varName).attributes = []; 115 | for attIdx = 1:natts 116 | meta.(varName).attributes(end+1).name = att_array(attIdx).Name; 117 | meta.(varName).attributes(end).value = att_array(attIdx).Value; 118 | end 119 | end 120 | 121 | end 122 | 123 | -------------------------------------------------------------------------------- /m/processing_tools/alignSGDiveParams.m: -------------------------------------------------------------------------------- 1 | function data = alignSGDiveParams(data, meta, params) 2 | %ALIGNSGDIVEPARAMS Align Seaglider dive parameters with column data. 3 | % 4 | % Syntax: 5 | % DATA = ALIGNSGDIVEPARAMS(DATA, META, PARAMS) 6 | % 7 | % Description: 8 | % DATA = ALIGNSGDIVEPARAMS(DATA, META, PARAMS) aligns the values of 9 | % Seaglider dive parameters in the fields of struct DATA selected by 10 | % character array or string cell array PARAMS with the data column fields. 11 | % It assigns each parameter value to the first record of the corresponding 12 | % dive in the final data column, and initializes all other entries as 13 | % invalid (NaN). 14 | % 15 | % Notes: 16 | % Some parameters like the target waypoint or the currents estimates are 17 | % provided by Seagliders only once per dive in the log file (.log), and they 18 | % are not timestamped. This function aligns them with the data collected 19 | % during the dive as if they were timestamped as the first dive record. For 20 | % some parameters (e.g. SENSOR_SECS) this might not be the nearest record. 21 | % 22 | % Examples: 23 | % data = alignSGDiveParams(data, meta, params) 24 | % 25 | % See also: 26 | % LOADSEAGLIDERDATA 27 | % 28 | % Authors: 29 | % Joan Pau Beltran 30 | 31 | % Copyright (C) 2014-2016 32 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 33 | % 34 | % 35 | % This program is free software: you can redistribute it and/or modify 36 | % it under the terms of the GNU General Public License as published by 37 | % the Free Software Foundation, either version 3 of the License, or 38 | % (at your option) any later version. 39 | % 40 | % This program is distributed in the hope that it will be useful, 41 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43 | % GNU General Public License for more details. 44 | % 45 | % You should have received a copy of the GNU General Public License 46 | % along with this program. If not, see . 47 | 48 | narginchk(3, 3); 49 | 50 | dive_select = ~cellfun(@isempty, {meta.engheaders.dive}'); 51 | dive_start = vertcat(meta.logheaders(dive_select).start); 52 | dive_start = [1900 + dive_start(:,3) dive_start(:, [1:2 4:6])]; 53 | dive_start_secs = etime(dive_start, dive_start(ones(size(dive_start,1),1),:)); 54 | record_secs = data.elaps_t; 55 | delta_secs = bsxfun(@minus, record_secs(:), dive_start_secs(:)'); 56 | delta_secs(delta_secs < 0) = nan; 57 | [first_records_offsets, first_records_indices] = min(delta_secs); 58 | dive_with_records = isfinite(first_records_offsets); 59 | first_records = false(size(record_secs)); 60 | first_records(first_records_indices(dive_with_records)) = true; 61 | other_records = ~first_records; 62 | param_name_list = cellstr(params); 63 | for param_name_idx = 1:numel(param_name_list) 64 | param_name = param_name_list{param_name_idx}; 65 | if isfield(data, param_name) 66 | data.(param_name)(first_records) = data.(param_name)(dive_with_records); 67 | if iscell(data.(param_name)) 68 | data.(param_name)(other_records) = {[]}; 69 | else 70 | data.(param_name)(other_records) = nan; 71 | end 72 | end 73 | end 74 | 75 | end 76 | -------------------------------------------------------------------------------- /m/processing_tools/applySeabirdPressureFilter.m: -------------------------------------------------------------------------------- 1 | function new_pressure = applySeabirdPressureFilter(time, old_pressure, time_constant) 2 | %APPLYPRESSUREFILTER Pressure filtering with regular resampling for Seabird sensor. 3 | % 4 | % Syntax: 5 | % NEW_PRESSURE = APPLYSEABIRDPRESSUREFILTER(TIME, OLD_PRESSURE, TIME_CONSTANT) 6 | % NEW_PRESSURE = APPLYSEABIRDPRESSUREFILTER(TIME, OLD_PRESSURE) 7 | % 8 | % Description: 9 | % NEW_PRESSURE = APPLYSEABIRDPRESSUREFILTER(TIME, OLD_PRESSURE, TIME_CONSTANT) 10 | % applies a low pass filter to the pressure time serie in vector OLD_PRESSURE 11 | % with irregular timestamps in vector TIME. The filter applied is the one in 12 | % function SEABIRDFILTER with duration parameter given by the scalar 13 | % TIME_CONSTANT. The filtered pressure is returned in vector NEW_PRESSURE. 14 | % 15 | % NEW_PRESSURE = APPLYSEABIRDPRESSUREFILTER(TIME, OLD_PRESSURE) applies 16 | % the low pass filter with default duration parameter of 4 time units. 17 | % 18 | % The filtering is performed as follows: 19 | % - Invalid values (NaN) in input are ignored, but preserved in the result. 20 | % - The signal is resampled at regular intervals of unit time length. 21 | % Hence, if TIME is given in seconds, the filter is applied to a new 22 | % sequence with sampling rate 1 Hz. 23 | % - The filter in function SEABIRDFILTER is applied to the resampled signal 24 | % with duration parameter TIME_CONSTANT. 25 | % - The resulting filtered signal is resampled at the original time 26 | % instants. 27 | % 28 | % Notes: 29 | % This function is a version of the function APPLYPRESSUREFILTER created by 30 | % Tomeu Garau. He is the true glider man. Main changes are: 31 | % - Time constant argument. 32 | % - Duplicate record handling removal. 33 | % - Coding style adaptions. 34 | % 35 | % Examples: 36 | % % Use default time constant parameter (4 seconds). 37 | % new_pressure = applySeabirdPressureFilter(time, old_pressure) 38 | % % Use custom time constant parameter. 39 | % new_pressure = applySeabirdPressureFilter(time, old_pressure, 6) 40 | % 41 | % See also: 42 | % SEABIRDFILTER 43 | % INTERP1 44 | % 45 | % Authors: 46 | % Bartolome Garau tgarau@socib.es 47 | 48 | % Copyright (C) 2013-2016 49 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 50 | % 51 | % 52 | % This program is free software: you can redistribute it and/or modify 53 | % it under the terms of the GNU General Public License as published by 54 | % the Free Software Foundation, either version 3 of the License, or 55 | % (at your option) any later version. 56 | % 57 | % This program is distributed in the hope that it will be useful, 58 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 59 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 60 | % GNU General Public License for more details. 61 | % 62 | % You should have received a copy of the GNU General Public License 63 | % along with this program. If not, see . 64 | 65 | narginchk(2, 3); 66 | 67 | % Check if time constant specified. 68 | if nargin < 3 69 | time_constant = 4; 70 | end 71 | 72 | % Initialize output. 73 | new_pressure = nan(size(old_pressure)); 74 | 75 | % Filter invalid values in original data. 76 | % The positive time test is needed to deal with odd data from initial 77 | % lines in Slocum segment files. 78 | good_rows = ~isnan(old_pressure) & (time > 0); 79 | old_pres_signal = old_pressure(good_rows); 80 | time_range = time(good_rows); 81 | 82 | % Interpolation routine interp1 requires all nodes to have unique independent 83 | % variable coordinates. This might not be the case when the CTD timestamp is 84 | % used. So check for uniqueness and data coherency. 85 | [time_range_unique, index_from, index_to] = unique(time_range); 86 | old_pres_unique = old_pres_signal(index_from); 87 | if any(old_pres_signal ~= old_pres_unique(index_to)) 88 | error('glider_toolbox:applySeabirdFilter:InconsistentData', ... 89 | 'Inconsistent pressure data.'); 90 | end 91 | 92 | % Set the pressure time series on a regular time basis of unit length. 93 | reg_time_range = min(time_range_unique):max(time_range_unique); 94 | reg_pres_signal = interp1(time_range_unique, old_pres_unique, reg_time_range); 95 | 96 | % Filter the regular time series. 97 | new_pres_signal = seabirdFilter(reg_pres_signal, time_constant, 1); 98 | 99 | % Set the time series on its original time instants. 100 | new_pres_signal = interp1(reg_time_range, new_pres_signal, time_range); 101 | 102 | % Return the filtered signal preserving original invalid values. 103 | new_pressure(good_rows) = new_pres_signal; 104 | 105 | end 106 | -------------------------------------------------------------------------------- /m/processing_tools/bar2dbar.m: -------------------------------------------------------------------------------- 1 | function dbar = bar2dbar(bar) 2 | %BAR2DBAR Convert pressure from bars to decibars. 3 | % 4 | % Syntax: 5 | % DBAR = BAR2DBAR(BAR) 6 | % 7 | % Description: 8 | % DBAR = BAR2DBAR(BAR) converts pressure readings in array BAR from bars to 9 | % decibars by multiplying by 10. 10 | % 11 | % Notes: 12 | % This is simply a convenience function to call the conversion with an 13 | % explicit name. 14 | % 15 | % Examples: 16 | % dbar = bar2dbar(bar) 17 | % 18 | % Authors: 19 | % Joan Pau Beltran 20 | 21 | % Copyright (C) 2014-2016 22 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 23 | % 24 | % 25 | % This program is free software: you can redistribute it and/or modify 26 | % it under the terms of the GNU General Public License as published by 27 | % the Free Software Foundation, either version 3 of the License, or 28 | % (at your option) any later version. 29 | % 30 | % This program is distributed in the hope that it will be useful, 31 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 | % GNU General Public License for more details. 34 | % 35 | % You should have received a copy of the GNU General Public License 36 | % along with this program. If not, see . 37 | 38 | narginchk(1, 1); 39 | 40 | dbar = bar * 10; 41 | 42 | end 43 | -------------------------------------------------------------------------------- /m/processing_tools/calibrateSBECT.m: -------------------------------------------------------------------------------- 1 | function [temp, cond] = calibrateSBECT(temp_freq, cond_freq, pres, temp_coefs, cond_coefs) 2 | %CALIBRATESBECT Calibrate Seabird Electronics CT sail. 3 | % 4 | % Syntax: 5 | % [TEMP, COND] = CALIBRATESBECT(TEMP_FREQ, COND_FREQ, PRES, TEMP_COEFS, COND_COEFS) 6 | % 7 | % Description: 8 | % [TEMP, COND] = CALIBRATESBECT(TEMP_FREQ, COND_FREQ, PRES, TEMP_COEFS, COND_COEFS) 9 | % applies the equations described in Seabird Electronics calibration sheet 10 | % to convert the temperature and conductivity raw measurements (Hz) in arrays 11 | % TEMP_FREQ and COND_FREQ to engineering units (ITS90 ºC and Siemens/m) 12 | % in arrays TEMP and COND, using the pressure readings in PRES (dbar) and the 13 | % calibration coefficients in arrays or structs TEMP_COEFS and COND_COEFS. 14 | % 15 | % The calibration equations are: 16 | % TEMP = 1/(T_G + T_H*ln(1/F_T) + T_I*ln(1/F_T)^2 + T_J*ln(1/F_T)^3) - 273.15 17 | % COND = 0.1*(C_G + C_H*F_C^2 + C_I*F_C^3 + C_J*F_C^4)/(1 + CTCOR*TEMP + CPCOR*PRES) 18 | % where 19 | % F_T: temperature signal frequency in kHz (TEMP_FREQ * 1e-3). 20 | % F_C: conductivity signal frequency in kHz (COND_FREQ * 1e-3). 21 | % T_G, T_H, T_I, T_J: temperature calibration coefficients. 22 | % These should be fields of struct TEMP_COEFS or its elements if it 23 | % is an array (in that order). 24 | % C_G, C_H, C_I, C_J, CTCOR, CPCOR: conductivity calibration coefficients. 25 | % These should be fields of struct COND_COEFS or its elements if it 26 | % is an array (in that order). 27 | % 28 | % Notes: 29 | % The equations and coefficients are provided in the calibration sheets of 30 | % the CT sails shipped with Seaglider gliders. They also appear in the 31 | % basestation file 'sg_calib_constants.m'. 32 | % 33 | % Examples: 34 | % temp_true = [1.0 4.5 15.0 18.5 24.0 29.0 32.5 ] 35 | % cond_true = [2.97836 3.28569 4.26827 4.61375 5.17227 5.69472 6.06756 ] 36 | % pres = 0; 37 | % temp_freq = [3387.875 3668.209 4609.999 4959.066 5544.757 6117.756 6542.459] 38 | % cond_freq = [5987.16 6214.10 6888.93 7110.73 7455.09 7763.03 7975.39 ] 39 | % temp_coefs = [ 4.38052489e-3 6.25478746e-4 2.34258763e-5 2.50671271e-6] 40 | % cond_coefs = [-9.92304872 1.11163373 -2.02979731e-3 2.29265437e-4 -9.57e-8 3.25e-6] 41 | % [temp, cond] = calibrateSBECT(temp_freq, cond_freq, pres, temp_coefs, cond_coefs) 42 | % 43 | % Authors: 44 | % Joan Pau Beltran 45 | 46 | % Copyright (C) 2014-2016 47 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 48 | % 49 | % 50 | % This program is free software: you can redistribute it and/or modify 51 | % it under the terms of the GNU General Public License as published by 52 | % the Free Software Foundation, either version 3 of the License, or 53 | % (at your option) any later version. 54 | % 55 | % This program is distributed in the hope that it will be useful, 56 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 57 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 58 | % GNU General Public License for more details. 59 | % 60 | % You should have received a copy of the GNU General Public License 61 | % along with this program. If not, see . 62 | 63 | narginchk(5, 5); 64 | 65 | if isstruct(temp_coefs) 66 | jihg_temp = [temp_coefs.t_j temp_coefs.t_i temp_coefs.t_h temp_coefs.t_g]; 67 | else 68 | jihg_temp = temp_coefs([4 3 2 1]); 69 | end 70 | 71 | if isstruct(cond_coefs) 72 | jih0g_cond = [cond_coefs.c_j cond_coefs.c_i cond_coefs.c_h 0 cond_coefs.c_g]; 73 | ctcor = cond_coefs.ctcor; 74 | cpcor = cond_coefs.cpcor; 75 | else 76 | jih0g_cond = [cond_coefs([4 3 2]) 0 cond_coefs(1)]; 77 | ctcor = cond_coefs(5); 78 | cpcor = cond_coefs(6); 79 | end 80 | 81 | temp = 1 ./ polyval(jihg_temp, log(1000 ./ temp_freq)) - 273.15; 82 | cond = 0.1 * ... 83 | polyval(jih0g_cond, cond_freq ./ 1000) ./ (1 + ctcor * temp + cpcor * pres); 84 | 85 | end 86 | -------------------------------------------------------------------------------- /m/processing_tools/calibrateWLECOBbFl2.m: -------------------------------------------------------------------------------- 1 | function [chlr, cdom, scat] = calibrateWLECOBbFl2(chlr_cnts, cdom_cnts, scat_cnts, chlr_coefs, cdom_coefs, scat_coefs) 2 | %CALIBRATEWLECOBBFL2 Calibrate WET Labs ECO Triplet Puck. 3 | % 4 | % Syntax: 5 | % [CHLR, CDOM, SCAT] = CALIBRATEWLECOBBFL2(CHLR_CNTS, CDOM_CNTS, SCAT_CNTS, CHLR_COEFS, CDOM_COEFS, SCAT_COEFS) 6 | % 7 | % Description: 8 | % [CHLR, CDOM, SCAT] = CALIBRATEWLECOBBFL2(CHLR_CNTS, CDOM_CNTS, SCAT_CNTS, CHLR_COEFS, CDOM_COEFS, SCAT_COEFS) 9 | % applies the affine transformation (scale and offset) described in WET Labs 10 | % calibration sheet to convert raw measurements (counts) of chlorophyll 11 | % concentration, CDOM concetration and scattering in arrays CHLR_CNTS, 12 | % CDOM_CNTS and SCAT_CNTS to engineering units (ug l-1, ppb and m-1 sr-1) 13 | % in arrays CHLR, CDOM, SCAT, using the calibration coefficients in arrays 14 | % or structs CHLR_COEFS, CDOM_COEFS and SCAT_COEFS. 15 | % 16 | % The calibration equation of each signal is a simple offset and scale: 17 | % CHLR = CHLR_SF*(CHLR_CNTS - CHLR_DC) 18 | % CDOM = CDOM_SF*(CDOM_CNTS - CDOM_DC) 19 | % SCAT = SCAT_SF*(SCAT_CNTS - SCAT_DC) 20 | % where 21 | % CHLR_SF and CHLR_DC: chlorophyll scale factor and dark counts. 22 | % These should be fields of struct CHLR_COEFS, shortened to SF and DC, 23 | % or its elements if it is an array (in that order). 24 | % CDOM_SF and CDOM_DC: CDOM scale factor and dark counts. 25 | % These should be fields of struct CDOM_COEF, shortened to SF and DC, 26 | % or its elements if it is an array (in that order). 27 | % SCAT_SF and SCAT_DC: scattering scale factor and dark counts. 28 | % These should be fields of struct SCAT_COEFS, shortened to SF and DC, 29 | % or its elements if it is an array (in that order). 30 | % 31 | % Notes: 32 | % The equations and coefficients are provided in the calibration sheets of 33 | % the ECO Triplet Puck shipped with Seaglider gliders. They also appear in 34 | % the basestation file 'sg_calib_constants.m'. 35 | % 36 | % Examples: 37 | % chlr_cnts = [50 51 51 57 63 80 83 83 81 72 68 67 64 57 56 54 52 51 50] 38 | % cdom_cnts = [45 49 50 50 51 56 57 59 57 60 57 61 58 58 58 57 57 60 56] 39 | % scat_cnts = [81 79 78 78 81 83 86 83 76 73 75 71 71 72 73 73 81 71 70] 40 | % chlr_coefs = [0.0118 38] 41 | % cdom_coefs = [0.0878 40] 42 | % scat_coefs = [3.51e-06 33] 43 | % [chlr, cdom, scat] = ... 44 | % calibrateWLECOBbFl2(chlr_cnts, cdom_cnts, scat_cnts, ... 45 | % chlr_coefs, cdom_coefs, scat_coefs) 46 | % 47 | % Authors: 48 | % Joan Pau Beltran 49 | 50 | % Copyright (C) 2014-2016 51 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 52 | % 53 | % 54 | % This program is free software: you can redistribute it and/or modify 55 | % it under the terms of the GNU General Public License as published by 56 | % the Free Software Foundation, either version 3 of the License, or 57 | % (at your option) any later version. 58 | % 59 | % This program is distributed in the hope that it will be useful, 60 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 61 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 62 | % GNU General Public License for more details. 63 | % 64 | % You should have received a copy of the GNU General Public License 65 | % along with this program. If not, see . 66 | 67 | narginchk(6, 6); 68 | 69 | if isstruct(chlr_coefs) 70 | sd_chlr = [chlr_coefs.sf chlr_coefs.dc]; 71 | else 72 | sd_chlr = chlr_coefs([1 2]); 73 | end 74 | if isstruct(cdom_coefs) 75 | sd_cdom = [cdom_coefs.sf cdom_coefs.dc]; 76 | else 77 | sd_cdom = cdom_coefs([1 2]); 78 | end 79 | if isstruct(scat_coefs) 80 | sd_scat = [scat_coefs.sf scat_coefs.dc]; 81 | else 82 | sd_scat = scat_coefs([1 2]); 83 | end 84 | 85 | chlr = sd_chlr(1)*(chlr_cnts - sd_chlr(2)); 86 | cdom = sd_cdom(1)*(cdom_cnts - sd_cdom(2)); 87 | scat = sd_scat(1)*(scat_cnts - sd_scat(2)); 88 | 89 | end 90 | -------------------------------------------------------------------------------- /m/processing_tools/cm2m.m: -------------------------------------------------------------------------------- 1 | function m = cm2m(cm) 2 | %BAR2DBAR Convert metric distance from centimeters to meters. 3 | % 4 | % Syntax: 5 | % M = CM2M(CM) 6 | % 7 | % Description: 8 | % M = CM2M(CM) converts metric readings in array CM from centimeters to 9 | % meters by multiplying by 0.01. 10 | % 11 | % Notes: 12 | % This is simply a convenience function to call the conversion with an 13 | % explicit name. 14 | % 15 | % Examples: 16 | % m = cm2m(cm) 17 | % 18 | % Authors: 19 | % Joan Pau Beltran 20 | 21 | % Copyright (C) 2014-2016 22 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 23 | % 24 | % 25 | % This program is free software: you can redistribute it and/or modify 26 | % it under the terms of the GNU General Public License as published by 27 | % the Free Software Foundation, either version 3 of the License, or 28 | % (at your option) any later version. 29 | % 30 | % This program is distributed in the hope that it will be useful, 31 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 | % GNU General Public License for more details. 34 | % 35 | % You should have received a copy of the GNU General Public License 36 | % along with this program. If not, see . 37 | 38 | narginchk(1, 1); 39 | 40 | m = cm * 0.01; 41 | 42 | end 43 | -------------------------------------------------------------------------------- /m/processing_tools/computeCumulativeDistance.m: -------------------------------------------------------------------------------- 1 | function distance = computeCumulativeDistance(latitude, longitude) 2 | %COMPUTECUMULATIVEDISTANCE Cumulate distance along given trajectory. 3 | % 4 | % Syntax: 5 | % DISTANCE = COMPUTECUMULATIVEDISTANCE(LATITUDE, LONGITUDE) 6 | % 7 | % Description: 8 | % DISTANCE = COMPUTECUMULATIVEDISTANCE(LATITUDE, LONGITUDE) computes the 9 | % cumulative distance (in km) of a trajectory defined by coordinate vectors 10 | % LATITUDE and LONGITUDE. DISTANCE, LATITUDE and LONGITUDE have the same 11 | % dimensions. Invalid values (NaN) are ignored but preserved in output. 12 | % 13 | % Notes: 14 | % Two functions may be used to compute distance between consecutive 15 | % geographical coordinates: 16 | % M_LLDIST (from M_Map toolbox) 17 | % SW_DIST (from CSIRO's SeaWater library) 18 | % Function M_LLDIST is preferred because its method (haversine) seems to be 19 | % more accurate. If it is not available, function SW_DIST is used instead. 20 | % 21 | % Examples: 22 | % latitude = [39.50 nan 39.50 nan 39.21 nan 39.23 nan nan nan 38.98 nan 38.98] 23 | % longitude = [ 2.18 nan nan nan 1.65 nan 1.28 nan 1.09 nan 1.09 nan 0.12] 24 | % distance = computeCumulativeDistance(latitude, longitude) 25 | % 26 | % See also: 27 | % M_LLDIST 28 | % SW_DIST 29 | % 30 | % Authors: 31 | % Joan Pau Beltran 32 | 33 | % Copyright (C) 2013-2016 34 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 35 | % 36 | % 37 | % This program is free software: you can redistribute it and/or modify 38 | % it under the terms of the GNU General Public License as published by 39 | % the Free Software Foundation, either version 3 of the License, or 40 | % (at your option) any later version. 41 | % 42 | % This program is distributed in the hope that it will be useful, 43 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 44 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 | % GNU General Public License for more details. 46 | % 47 | % You should have received a copy of the GNU General Public License 48 | % along with this program. If not, see . 49 | 50 | narginchk(2, 2); 51 | 52 | distance = nan(size(latitude)); 53 | valid_point_sel = ~(isnan(latitude) | isnan(longitude)); 54 | latitude_valid = latitude(valid_point_sel); 55 | longitude_valid = longitude(valid_point_sel); 56 | switch sum(valid_point_sel) 57 | case 0 58 | case 1 59 | distance(valid_point_sel) = 0; 60 | otherwise 61 | if exist('m_lldist', 'file') == 2 % exists and is a file (not a folder) 62 | distance(valid_point_sel) = ... 63 | cumsum([0; m_lldist(longitude_valid(:), latitude_valid(:))]); 64 | elseif exist('sw_dist', 'file') == 2 65 | distance(valid_point_sel) = ... 66 | cumsum([0; sw_dist(latitude_valid(:), longitude_valid(:), 'km')]); 67 | else 68 | error('glider_toolbox:computeCumulativeDistance:MissingBackendFunction', ... 69 | 'Missing backend functions: m_lldist (preferred) or sw_dist'); 70 | end 71 | end 72 | 73 | end 74 | -------------------------------------------------------------------------------- /m/processing_tools/fillSGMissingGPSDate.m: -------------------------------------------------------------------------------- 1 | function [stampnum, hhmmss, ddmmyy] = fillSGMissingGPSDate(hhmmss, ddmmyy) 2 | %FILLSGMISSINGGPSDATE Fill missing date component of Seaglider GPS timestamps. 3 | % 4 | % Syntax: 5 | % STAMPNUM = FILLSGMISSINGGPSDATE(DDMMYY, HHMMSS) 6 | % [STAMPNUM, HHMMSS, DDMMYY] = FILLSGMISSINGGPSDATE(HHMMSS, DDMMYY) 7 | % 8 | % Description: 9 | % STAMPNUM = FILLSGMISSINGGPSDATE(DDMMYY, HHMMSS) fills the date component 10 | % of GPS timestamps given by character arrays or string cell arrays HHMMSS 11 | % and DDMMYY and returns them as serial date numbers in array STARTNUM. 12 | % See note below. 13 | % 14 | % [STAMPNUM, HHMMSS, DDMMYY] = FILLSGMISSINGGPSDATE(HHMMSS, DDMMYY) also 15 | % returns the same input arrays HHMMSS and DDMMYY but with the empty 16 | % entries in DDMMYY filled with the corresponding date component value. 17 | % 18 | % Notes: 19 | % GPS lines in Seaglider log may have no date component and the corresponding 20 | % entries of input DDMMYY will be empty. Those entries are filled computing 21 | % the corresponding date from the next timestamp with a date component and 22 | % taking into account day roll backs inferred from the time components. 23 | % 24 | % Examples: 25 | % stampvec = fillSGMissingGPSTimestamp(hhmmss, ddmmyy) 26 | % 27 | % See also: 28 | % 29 | % Authors: 30 | % Joan Pau Beltran 31 | 32 | % Copyright (C) 2014-2016 33 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 34 | % 35 | % 36 | % This program is free software: you can redistribute it and/or modify 37 | % it under the terms of the GNU General Public License as published by 38 | % the Free Software Foundation, either version 3 of the License, or 39 | % (at your option) any later version. 40 | % 41 | % This program is distributed in the hope that it will be useful, 42 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 43 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 44 | % GNU General Public License for more details. 45 | % 46 | % You should have received a copy of the GNU General Public License 47 | % along with this program. If not, see . 48 | 49 | narginchk(2, 2); 50 | 51 | nodate = cellfun(@isempty, cellstr(ddmmyy)); 52 | stampvec(~nodate, :) = ... 53 | datevec(strcat(ddmmyy(~nodate,:),hhmmss(~nodate,:)), 'ddmmyyHHMMSS'); 54 | nodate_boundary = find([true; xor(nodate(1:end-1), nodate(2:end))]); 55 | for i = numel(nodate_boundary):-1:2 56 | index_curr = nodate_boundary(i); 57 | index_prev = nodate_boundary(i-1); 58 | if nodate(index_prev) 59 | stampvec(index_prev:index_curr-1, :) = ... 60 | datevec(strcat(ddmmyy(index_curr,:), hhmmss(index_prev:index_curr-1,:)), ... 61 | 'ddmmyyHHMMSS'); 62 | dateroll = 0 > diff(datenum(stampvec(index_prev:index_curr,:))); 63 | stampvec(index_prev:index_curr-1, 3) = ... 64 | stampvec(index_prev:index_curr-1, 3) - flipud(cumsum(flipud(dateroll))); 65 | end 66 | end 67 | stampnum = datenum(stampvec); 68 | if nargout > 1 69 | if ischar(ddmmyy) 70 | ddmmyy(nodate, 1:6) = datestr(stampnum(nodate), 'ddmmyy'); 71 | else 72 | ddmmyy(nodate) = cellstr(datestr(stampnum(nodate), 'ddmmyy')); 73 | end 74 | end 75 | 76 | end 77 | -------------------------------------------------------------------------------- /m/processing_tools/findTransects.m: -------------------------------------------------------------------------------- 1 | function transect_index = findTransects(waypoint_latitude, waypoint_longitude) 2 | %FINDTRANSECTS Identify transects from waypoint coordinates. 3 | % 4 | % Syntax: 5 | % TRANSECT_INDEX = FINDTRANSECTS(WAYPOINT_LATITUDE, WAYPOINT_LONGITUDE) 6 | % 7 | % Description: 8 | % TRANSECT_INDEX = FINDTRANSECTS(WAYPOINT_LATITUDE, WAYPOINT_LONGITUDE) 9 | % identifies transects (travels from one waypoint to the next one) from 10 | % waypoint coordinates in vectors WAYPOINT_LATITUDE and WAIPONT_LONGITUDE, 11 | % and flags each point with the index of the transect the point belongs to, 12 | % starting from 1. WAYPOINT_LATITUDE, WAYPOINT_LONGITUDE and TRANSECT_INDEX 13 | % have the same length. 14 | % 15 | % Notes: 16 | % A new transect starts whenever a change in latitude or longitude waypoint 17 | % coordinate is found. Transects are numbered cumulating changes of latitude 18 | % or longitude coordinates, ignoring invalid values (NaN) in the sequences. 19 | % 20 | % This function is based on the previous work by Tomeu Garau, in a function 21 | % called GETTRANSECTS. He is the true glider man. 22 | % 23 | % Examples: 24 | % waypoint_latitude = [39.50 nan 39.50 nan 39.21 nan 39.23 nan nan nan 38.98 nan 38.98] 25 | % waypoint_longitude = [ 2.18 nan nan nan 1.65 nan 1.28 nan 1.09 nan 1.09 nan 0.12] 26 | % transect_index = findTransects(waypoint_latitude, waypoint_longitude) 27 | % figure 28 | % subplot(2,1,1) 29 | % plotyy(waypoint_latitude, 'og', waypoint_longitude, 'or') 30 | % subplot(2,1,2) 31 | % stairs(transect_index) 32 | % 33 | % Authors: 34 | % Joan Pau Beltran 35 | 36 | % Copyright (C) 2013-2016 37 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 38 | % 39 | % 40 | % This program is free software: you can redistribute it and/or modify 41 | % it under the terms of the GNU General Public License as published by 42 | % the Free Software Foundation, either version 3 of the License, or 43 | % (at your option) any later version. 44 | % 45 | % This program is distributed in the hope that it will be useful, 46 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 47 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 48 | % GNU General Public License for more details. 49 | % 50 | % You should have received a copy of the GNU General Public License 51 | % along with this program. If not, see . 52 | 53 | narginchk(2, 2); 54 | 55 | waypoint_coordinates = [waypoint_latitude(:) waypoint_longitude(:)]; 56 | 57 | % Initialize transect index to have the same dimensions as given inputs. 58 | % This also handles degenerated cases (empty or all data invalid). 59 | transect_index = ones(size(waypoint_latitude)); 60 | if ~isempty(waypoint_coordinates) 61 | waypoint_coordinate_change = false(size(waypoint_coordinates)); 62 | for i = 1:2 63 | coord_valid_sel = ~isnan(waypoint_coordinates(:,i)); 64 | coord_valid_ind = find(coord_valid_sel); 65 | coord_valid = waypoint_coordinates(coord_valid_sel, i); 66 | coord_valid_change = [false; (coord_valid(2:end) ~= coord_valid(1:end-1))]; 67 | waypoint_coordinate_change(coord_valid_ind(coord_valid_change), i) = true; 68 | end 69 | transect_index(:) = 1 + cumsum(any(waypoint_coordinate_change, 2)); 70 | end 71 | 72 | end 73 | -------------------------------------------------------------------------------- /m/processing_tools/nmea2deg.m: -------------------------------------------------------------------------------- 1 | function varargout = nmea2deg(varargin) 2 | %NMEA2DEG Convert NMEA latitude and/or longitude degrees to decimal degrees. 3 | % 4 | % Syntax: 5 | % DEG = NMEA2DEG(NMEA) 6 | % [DEGLAT, DEGLON] = NMEA2DEG(NMEALAT, NMEALON) 7 | % 8 | % Description: 9 | % DEG = NMEA2DEG(NMEA) converts the scalar or array NMEA from NMEA latitude 10 | % or longitude degrees to decimal degrees applying the transformation: 11 | % DEG = FIX(NMEA/100) + REM(NMEA,100)/60; 12 | % 13 | % [DEGLAT, DEGLON] = NMEA2DEG(NMEALAT, NMEALON) performs the same conversion 14 | % to each of its input arguments separately. 15 | % 16 | % Examples: 17 | % nmea2deg(3330.00) 18 | % nmea = [36015.00 -445.25] 19 | % deg = nmea2deg(nmea) 20 | % nmealat = 3900.61662 21 | % nmealon = 257.99996 22 | % [deglat, deglon] = nmea2deg(nmealat, nmealon) 23 | % 24 | % Notes: 25 | % The input values are not checked to be valid NMEA coordinate values. 26 | % So no warning is produced if the degree digits are out of [0,180] or 27 | % the integral part of de minute digits are out of [00,59]. 28 | % 29 | % See also: 30 | % FIX 31 | % REM 32 | % 33 | % Authors: 34 | % Joan Pau Beltran 35 | 36 | % Copyright (C) 2013-2016 37 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 38 | % 39 | % 40 | % This program is free software: you can redistribute it and/or modify 41 | % it under the terms of the GNU General Public License as published by 42 | % the Free Software Foundation, either version 3 of the License, or 43 | % (at your option) any later version. 44 | % 45 | % This program is distributed in the hope that it will be useful, 46 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 47 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 48 | % GNU General Public License for more details. 49 | % 50 | % You should have received a copy of the GNU General Public License 51 | % along with this program. If not, see . 52 | 53 | narginchk(1, 2); 54 | 55 | for varargidx = 1:numel(varargin) 56 | nmea = varargin{varargidx}; 57 | deg = fix(nmea/100) + rem(nmea,100)/60; 58 | varargout{varargidx} = deg; 59 | end 60 | 61 | end 62 | -------------------------------------------------------------------------------- /m/processing_tools/profileArea.m: -------------------------------------------------------------------------------- 1 | function a = profileArea(x1, y1, x2, y2) 2 | %PROFILEAREA Compute the area eclosed by two profiles. 3 | % 4 | % Syntax: 5 | % A = PROFILEAREA(X1, Y1, X2, Y2) 6 | % 7 | % Description: 8 | % A = PROFILEAREA(X1, Y1, X2, Y2) returns the area A enclosed by consecutive 9 | % profiles with opposite directions in vectors X1 and Y1, and X2 and Y2. 10 | % 11 | % Notes: 12 | % This function is a simpler rewording of a previous function by Tomeu Garau, 13 | % called BUILDPOLYGON. He is the true glider man. 14 | % 15 | % The union of the two profiles may be a complex polygon (self-intersecting). 16 | % Hence, the area is computed decomposing it in triangles with the function 17 | % POLY2TRY, and adding the absolute value of the area of each triangular 18 | % component returned by POLYAREA. 19 | % 20 | % Profile points with invalid coordinates (NaN) are ignored when building the 21 | % polygonal contour. 22 | % 23 | % Examples: 24 | % x1 = [ 0 -1 1 0] 25 | % y1 = [ 2 1 -1 -2] 26 | % x2 = [ 0 -1 1 0] 27 | % y2 = [-2 -1 1 2] 28 | % figure 29 | % hold on 30 | % plot(x1, y1, 'b', x2, y2, 'r') 31 | % a = profileArea(x1, y1, x2, y2) 32 | % % POLYAREA would fail because of complex polygon: 33 | % a = polyarea([x1(:); x2(:)], [y1(:); y2(:)]) 34 | % 35 | % See also: 36 | % POLYAREA 37 | % 38 | % Authors: 39 | % Joan Pau Beltran 40 | 41 | % Copyright (C) 2013-2016 42 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 43 | % 44 | % 45 | % This program is free software: you can redistribute it and/or modify 46 | % it under the terms of the GNU General Public License as published by 47 | % the Free Software Foundation, either version 3 of the License, or 48 | % (at your option) any later version. 49 | % 50 | % This program is distributed in the hope that it will be useful, 51 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 52 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 53 | % GNU General Public License for more details. 54 | % 55 | % You should have received a copy of the GNU General Public License 56 | % along with this program. If not, see . 57 | 58 | narginchk(4, 4); 59 | 60 | % Join both profiles discarding invalid coordinates. 61 | % The resulting contour may be a complex polygon. 62 | % Decompose it in triangular components and sum up their areas. 63 | % We could use ISFINITE instead of ISNAN to discard all non-numerical values. 64 | % However, this may not be practical because the decomposition would omit 65 | % infinite triangles, and their contribution to the total area would be 0. 66 | xy = [x1(:) y1(:); x2(:) y2(:)]; 67 | xy = xy(~any(isnan(xy), 2), :); 68 | [x, y] = poly2tri(xy(:,1), xy(:,2)); 69 | a = sum(polyarea(x, y)); 70 | 71 | end 72 | -------------------------------------------------------------------------------- /m/processing_tools/seabirdFilter.m: -------------------------------------------------------------------------------- 1 | function outputSignal = seabirdFilter(inputSignal, timeConstant, samplingPeriod) 2 | %SEABIRDFILTER Applies a low-pass filter to an input signal 3 | % 4 | % Syntax: 5 | % outputSignal = seabirdFilter(inputSignal, timeConstant, samplingPeriod) 6 | % 7 | % Description: 8 | % The filter runs a low-pass filter on an input signal. A low-pass filter 9 | % smoothes high frequency (rapidly changing) data. To produce zero phase 10 | % (no time shift), the filter is first run forward through the data and then 11 | % run backward through the data, so that no delays are caused by the filter. 12 | % This filter is described in SeaBird Data Processing Manual (page 91). 13 | % 14 | % Inputs: 15 | % inputSignal - Signal to be filtered 16 | % timeConstant - Duration of the filter (in s) 17 | % samplingPeriod - Sampling period of the input signal (in s) 18 | % 19 | % Outputs: 20 | % outputSignal - inputSignal filtered with desired parameters 21 | % 22 | % Example: 23 | % dataSize = 500; 24 | % samplingPeriod = 2; 25 | % time = (0:(dataSize-1))' * samplingPeriod; 26 | % originalSignal = 100 * (1 + sin(linspace(0, 2 * pi, dataSize)')); 27 | % someNoise = 10 * (rand(dataSize, 1) - 0.5); 28 | % inputSignal = originalSignal + someNoise; 29 | % outputSignal = seabirdFilter(inputSignal, 4, samplingPeriod); 30 | % figure(1); clf; 31 | % plotHandle = ... 32 | % plot(time, originalSignal, 'k', ... 33 | % time, inputSignal, 'b', ... 34 | % time, outputSignal, 'r'); 35 | % legend(plotHandle, 'original signal', 'noisy signal', 'filtered signal'); 36 | % xlabel('Time (secs)'); 37 | % ylabel('Depth (meters)'); 38 | % title('Glider depth'); 39 | % 40 | % See also: 41 | % BUTTER 42 | % BUTTORD 43 | % CHEBY1 44 | % FILTER 45 | % 46 | % Other m-files required: none 47 | % Subfunctions: none 48 | % MAT-files required: none 49 | % Dec 2010; Last revision: 23-Dec-2010 50 | % 51 | % Authors: 52 | % Bartolome Garau 53 | 54 | % Copyright (C) 2013-2016 55 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 56 | % 57 | % 58 | % This program is free software: you can redistribute it and/or modify 59 | % it under the terms of the GNU General Public License as published by 60 | % the Free Software Foundation, either version 3 of the License, or 61 | % (at your option) any later version. 62 | % 63 | % This program is distributed in the hope that it will be useful, 64 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 65 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 66 | % GNU General Public License for more details. 67 | % 68 | % You should have received a copy of the GNU General Public License 69 | % along with this program. If not, see ." 70 | 71 | % Store original size of input signal and 72 | % make sure it is a column vector (later will be flipped ud) 73 | origSize = size(inputSignal); 74 | inputSignal = inputSignal(:); 75 | 76 | % Precompute some filter constants 77 | magicNumber = 2 * timeConstant / samplingPeriod; 78 | A = 1 / ( 1 + magicNumber); 79 | B = (1 - magicNumber) * A; 80 | 81 | % Pass the filter twice, first forward and then backward 82 | % to produce zero phase and thus avoid delays 83 | theSignal = inputSignal; 84 | for filterPass = 1:2 85 | outputSignal = theSignal; 86 | % Loop through the scans, recursive filter 87 | for scanIdx = 2:length(theSignal) 88 | outputSignal(scanIdx) = ... 89 | A .* (theSignal(scanIdx) + theSignal(scanIdx - 1)) -... 90 | B .* outputSignal(scanIdx - 1); 91 | end 92 | % Make the signal to be filtered the output 93 | % from the first filter pass, but turned upside down 94 | theSignal = flipud(outputSignal); 95 | end 96 | 97 | % The result from the second filter pass is in theSignal, 98 | % so reshape it to be same size as input signal 99 | outputSignal = reshape(theSignal, origSize); 100 | 101 | end 102 | -------------------------------------------------------------------------------- /m/processing_tools/sgcur2cart.m: -------------------------------------------------------------------------------- 1 | function [eastward, northward] = sgcur2cart(speed, direction) 2 | %SGCUR2CART Transform Seaglider water velocity speed and direction estimates to eastward and northward components. 3 | % 4 | % Syntax: 5 | % [EASTWARD, NORTHWARD] = SGCUR2CART(SPEED, DIRECTION) 6 | % 7 | % Description: 8 | % [EASTWARD, NORTHWARD] = SGCUR2CART(SPEED, DIRECTION) computes the eastward 9 | % and northward components of the sea water velocity (m s-1) from magnitude 10 | % and direction estimates in SPEED (m s-1) and DIRECTION (degrees) 11 | % provided by Seaglider gliders. All arguments are the same size. 12 | % 13 | % Notes: 14 | % This is just a convenience function to give a name to the conversion. 15 | % It is a shortcut to the built-in polar to cartesian conversion, POL2CART, 16 | % with needed angular unit conversion and order shift of output arguments. 17 | % 18 | % Examples: 19 | % [eastward, northward] = sgcur2cart(speed, direction) 20 | % 21 | % See also: 22 | % POL2CART 23 | % 24 | % Authors: 25 | % Joan Pau Beltran 26 | 27 | % Copyright (C) 2014-2016 28 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 29 | % 30 | % 31 | % This program is free software: you can redistribute it and/or modify 32 | % it under the terms of the GNU General Public License as published by 33 | % the Free Software Foundation, either version 3 of the License, or 34 | % (at your option) any later version. 35 | % 36 | % This program is distributed in the hope that it will be useful, 37 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 38 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 39 | % GNU General Public License for more details. 40 | % 41 | % You should have received a copy of the GNU General Public License 42 | % along with this program. If not, see . 43 | 44 | narginchk(2, 2); 45 | 46 | [northward, eastward] = pol2cart(deg2rad(direction), speed); 47 | 48 | end 49 | -------------------------------------------------------------------------------- /m/processing_tools/sgdepth2pres.m: -------------------------------------------------------------------------------- 1 | function pres = sgdepth2pres(depth) 2 | %SGDEPTH2PRES Reverse Seaglider pressure to depth conversion. 3 | % 4 | % Syntax: 5 | % PRES = SGDEPTH2PRES(DEPTH) 6 | % 7 | % Description: 8 | % PRES = SGDEPTH2PRES(DEPTH) converts depth estimates (cm) in array DEPTH to 9 | % pressure readings in engineering units (dbar) in array PRES, reversing the 10 | % on board conversion performed by a Seaglider glider (see note below). 11 | % 12 | % Notes: 13 | % Seaglider gliders do not report pressure measurements. Instead, the 14 | % pressure readings are converted to approximate depth values using a 15 | % constant scale factor of 0.685 psig/m. This function reverses that 16 | % conversion using that factor and 14.503774 psi/bar. 17 | % 18 | % Examples: 19 | % pres = sgdepth2pres(depth) 20 | % 21 | % Authors: 22 | % Joan Pau Beltran 23 | 24 | % Copyright (C) 2014-2016 25 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 26 | % 27 | % 28 | % This program is free software: you can redistribute it and/or modify 29 | % it under the terms of the GNU General Public License as published by 30 | % the Free Software Foundation, either version 3 of the License, or 31 | % (at your option) any later version. 32 | % 33 | % This program is distributed in the hope that it will be useful, 34 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 35 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 36 | % GNU General Public License for more details. 37 | % 38 | % You should have received a copy of the GNU General Public License 39 | % along with this program. If not, see . 40 | 41 | psig2m = 0.685; 42 | bar2psi = 14.503774; 43 | pres = depth / (psig2m * bar2psi * 10); 44 | 45 | end 46 | -------------------------------------------------------------------------------- /m/processing_tools/sxgoodfix.m: -------------------------------------------------------------------------------- 1 | function good = sxgoodfix(longitude, latitude, state) 2 | %SXGOODFIX Discard null and repeated fixes in SeaExplorer position data. 3 | % 4 | % Syntax: 5 | % GOOD = SXGOODFIX(LONGITUDE, LATITUDE, STATE) 6 | % 7 | % Description: 8 | % GOOD = SXGOODFIX(LONGITUDE, LATITUDE, STATE) returns a boolean vector 9 | % GOOD indicating whether the position coordinates in vectors LONGITUDE 10 | % and LATITUDE taken in the glider state in vector STATE are taken in the 11 | % right state, are valid and not null, and are not a repetition of the 12 | % previous fix (see note on defects of SeaExplorer position data). 13 | % 14 | % Notes: 15 | % SeaExplorer position data both in glider and payload data set is defective. 16 | % According to the manufacturer, SeaExplorer gliders can only get valid GPS 17 | % fixes while the glider is in 'transmitting state' (116). 18 | % The glider state and the fix coordinates (in NMEA degrees format) 19 | % are the columns `NAV_RESOURCE`, `NAV_LONGITUDE`, and `NAV_LATITUDE` 20 | % in the glider data set, and the columns `Lon`, `Lat`, and `NavState` 21 | % in the payload data set. However, wrong position coordinates may appear 22 | % even in the right state: 23 | % - Entries equal to [0, 0] may appear when there is no proper fix 24 | % instead of the expected value [NaN, NaN]. 25 | % - Apparently right entries that are in fact repetitions of the previous 26 | % fix, which can be taken too far away in the past. 27 | % Hence, this function flags a position as good only if: 28 | % - It was taken in the right state ('transmitting state', 116). 29 | % - The coordinates are valid (not NaN). 30 | % - It is not null (both coordinates equal to zero). 31 | % - It differs from the previous good position. 32 | % 33 | % Note that the last two conditions may discard potentially valid fixes: 34 | % fixes effectively at the location [0, 0] (it is not on land), 35 | % or consecutive fixes that are effectively at the same location 36 | % or so close that due to the number of decimal digits used in the data file 37 | % they result in the same NMEA coordinates (although with 3 decimal digits 38 | % in NMEA degrees points at a distance of >=3 meters should have 39 | % distinguishable coordinates at all locations). 40 | % 41 | % Examples: 42 | % data = [105 0.000 0.000 43 | % 115 0.000 0.000 44 | % 115 0.000 0.000 45 | % 116 0.000 0.000 46 | % 116 0.000 0.000 47 | % 116 4303.860 641.011 48 | % 116 4303.857 641.004 49 | % 116 4303.852 640.996 50 | % 116 4303.848 640.989 51 | % 110 4303.848 640.989 52 | % 110 4303.848 640.989 53 | % NaN NaN NaN 54 | % NaN NaN NaN 55 | % NaN NaN NaN 56 | % 117 4303.848 640.989 57 | % 117 4303.848 640.989 58 | % 116 4303.848 640.989 59 | % 116 4303.479 642.385 60 | % 116 4303.477 642.377 61 | % 116 4303.477 642.377 62 | % 116 4303.471 642.363 63 | % 116 4303.467 642.355 64 | % 116 4303.467 642.355 65 | % 116 4303.467 642.355 66 | % 116 4303.449 642.313 67 | % 116 4303.442 642.299]; 68 | % longitude = data(:, 3); 69 | % latitude = data(:, 2); 70 | % state = data(:, 1); 71 | % good = sxgoodfix(longitude,latitude, state) 72 | % data(good, :) 73 | % 74 | % Authors: 75 | % Joan Pau Beltran 76 | 77 | % Copyright (C) 2016 78 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears. 79 | % 80 | % 81 | % This program is free software: you can redistribute it and/or modify 82 | % it under the terms of the GNU General Public License as published by 83 | % the Free Software Foundation, either version 3 of the License, or 84 | % (at your option) any later version. 85 | % 86 | % This program is distributed in the hope that it will be useful, 87 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 88 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 89 | % GNU General Public License for more details. 90 | % 91 | % You should have received a copy of the GNU General Public License 92 | % along with this program. If not, see . 93 | 94 | narginchk(3, 3); 95 | 96 | good = (state == 116) ... 97 | & ~(isnan(longitude) | isnan(latitude)) ... 98 | & ~((longitude == 0) & (latitude == 0)); 99 | good_indices = find(good); 100 | good(good_indices(2:end)) = (diff(longitude(good)) ~= 0) ... 101 | & (diff(latitude (good)) ~= 0); 102 | 103 | end 104 | -------------------------------------------------------------------------------- /m/qc_tools/postProcessQCGliderData.m: -------------------------------------------------------------------------------- 1 | function [ data_qc, meta_qc ] = postProcessQCGliderData( data_proc, meta_proc, varargin ) 2 | % POSTPROCESSQCGLIDERDATA Perform quality control to post process data 3 | % 4 | % Syntax: 5 | % [DATA_QC, META_QC] = POSTPROCESSQCGLIDERDATA( DATA_PROC, META_PROC ) 6 | % [DATA_QC, META_QC] = POSTPROCESSQCGLIDERDATA( DATA_PROC, META_PROC, PARAM1, VAL1 ) 7 | % 8 | % Description: 9 | % POSTPROCESSQCGLIDERDATA is intended to perform the quality control to 10 | % post process data. Currently, this function only creates the required 11 | % variables that are required by the NetCDF-EGO format and fills them 12 | % with default values. 13 | % 14 | % Input: 15 | % 16 | % DATA_PROC should be a struct in the format returned by POSTPROCESSGLIDERDATA, 17 | % where each field is a sequence of measurements of the variable with the 18 | % same name. 19 | 20 | % META_PROC should be a struct in the format returned by POSTPROCESSGLIDERDATA, 21 | % where each field is a sequence of meta data of the variable with the 22 | % same name. 23 | % 24 | % Output: 25 | % 26 | % DATA_QC is a struct in the same format as DATA_PROC, with time sequences 27 | % resulting from the processing actions described above, performed according 28 | % to the options described below. 29 | % 30 | % META_QC is also a struct with one field per variable, adding processing 31 | % metadata to any existing metadata in META_PROC. 32 | % 33 | % 34 | % Authors: 35 | % Miguel Charcos Llorens 36 | % 37 | % Copyright (C) 2013-2016 38 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 39 | % 40 | % 41 | % This program is free software: you can redistribute it and/or modify 42 | % it under the terms of the GNU General Public License as published by 43 | % the Free Software Foundation, either version 3 of the License, or 44 | % (at your option) any later version. 45 | % 46 | % This program is distributed in the hope that it will be useful, 47 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 48 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 49 | % GNU General Public License for more details. 50 | % 51 | % You should have received a copy of the GNU General Public License 52 | % along with this program. If not, see . 53 | 54 | %% Check inputs. 55 | narginchk(2,2) 56 | 57 | %% Initialize results 58 | data_qc = data_proc; 59 | meta_qc = meta_proc; 60 | 61 | %% Start assembling. 62 | names_data = fieldnames(data_qc); 63 | for i=1:numel(names_data) 64 | var_name = names_data{i}; 65 | if isnumeric(data_qc.(var_name)) && ... 66 | ~strcmp(var_name(1:min(8,length(var_name))), 'history_') 67 | new_name = strcat(names_data{i},'_QC'); 68 | data_qc.(new_name) = zeros(size(data_qc.(var_name))); 69 | meta_qc.(new_name).sources = var_name; 70 | meta_qc.(new_name).method = 'default0'; 71 | 72 | new_name = strcat(names_data{i},'_UNCERTAINTY'); 73 | data_qc.(new_name) = zeros(size(data_qc.(var_name))); 74 | meta_qc.(new_name).sources = var_name; 75 | meta_qc.(new_name).method = 'default0'; 76 | end 77 | end 78 | 79 | %% Special cases 80 | % Geospatial Quality control 81 | if isfield(data_qc, 'latitude') && ... 82 | isfield(data_qc, 'longitude') 83 | meta_qc.position_QC.sources = 'latitude longitude'; 84 | meta_qc.position_QC.method = 'default0'; 85 | data_qc.position_QC = zeros(size(data_qc.latitude)); 86 | 87 | meta_qc.position_UNCERTAINTY.sources = 'latitude longitude'; 88 | meta_qc.position_UNCERTAINTY.method = 'default0'; 89 | data_qc.position_UNCERTAINTY = zeros(size(data_qc.latitude)); 90 | end 91 | 92 | % Geospatial GPS Quality control 93 | if isfield(data_qc, 'latitude_gps') && ... 94 | isfield(data_qc, 'longitude_gps') 95 | meta_qc.position_gps_QC.sources = 'latitude_gps longitude_gps'; 96 | meta_qc.position_gps_QC.method = 'default0'; 97 | data_qc.position_gps_QC = zeros(size(data_qc.latitude_gps)); 98 | 99 | meta_qc.position_gps_UNCERTAINTY.sources = 'latitude_gps longitude_gps'; 100 | meta_qc.position_gps_UNCERTAINTY.method = 'default0'; 101 | data_qc.position_gps_UNCERTAINTY = zeros(size(data_qc.latitude_gps)); 102 | end 103 | 104 | % dates Quality control 105 | data_qc.deployment_start_QC = -128; % TODO: verify value 106 | meta_qc.deployment_start_QC.sources = 'deployment_start'; 107 | meta_qc.deployment_start_QC.method = 'default0'; 108 | 109 | data_qc.deployment_end_QC = -128; % TODO: verify value 110 | meta_qc.deployment_end_QC.sources = 'deployment_start'; 111 | meta_qc.deployment_end_QC.method = 'default0'; 112 | 113 | end -------------------------------------------------------------------------------- /m/qc_tools/processQCGliderData.m: -------------------------------------------------------------------------------- 1 | function [ data_qc, meta_qc ] = processQCGliderData( data_proc, meta_proc, varargin ) 2 | % TODO: This is to be completed later, for now is to add a default value to _QC 3 | % variables for EGO formats 4 | 5 | data_qc = data_proc; 6 | meta_qc = meta_proc; 7 | 8 | end 9 | 10 | -------------------------------------------------------------------------------- /m/setupMexPoly2tri.m: -------------------------------------------------------------------------------- 1 | function setupMexPoly2tri() 2 | %SETUPMEXPOLY2TRI Build mex file for polygon triangulation function POLY2TRI. 3 | % 4 | % Syntax: 5 | % SETUPMEXPOLY2TRI() 6 | % 7 | % Description: 8 | % SETUPMEXPOLY2TRI() builds a mex file implementing the function POLY2TRI, 9 | % that performs polygon triangulation based on the General Polygon Clipper 10 | % library (GPC). GPC should be installed from the non-free section of the 11 | % official repositories on Debian based distributions, in which case the mex 12 | % file is built using the following attributes: 13 | % TARGET: 14 | % /path/to/poly2tri.mex(a64) 15 | % SOURCES: 16 | % /path/to/poly2tri.c 17 | % INCLUDES: 18 | % none 19 | % LIBRARIES: 20 | % -l gpcl 21 | % Alternatively, it is possible to build the mex file using the GPC sources 22 | % directly. This is useful on systems that do not distribute the GPC library, 23 | % or to use a version of GPC different from the one installed in the system. 24 | % The GPC sources should be downloaded from the official web site and 25 | % extracted to a directory called 'gpcl' in the same directory than the mex 26 | % file source: 27 | % TARGET: 28 | % /path/to/poly2tri.mex(a64) 29 | % SOURCES: 30 | % /path/to/poly2tri.c /path/to/gpcl/gpc.c 31 | % INCLUDES: 32 | % /path/to/gpcl/gpc.h 33 | % LIBRARIES: 34 | % none 35 | % Please note that when using this build rule, mex file and library sources 36 | % are compiled together. Hence the resulting binary might be slightly bigger. 37 | % 38 | % Notes: 39 | % GPC is a library developed by Alan Murta at the University of Manchester, 40 | % freely available for non-profit use: 41 | % 42 | % 43 | % On Debian based systems, GPC library may be installed from the non-free 44 | % section of the official repositories running the following command as root: 45 | % apt-get install libgpcl-dev 46 | % 47 | % This function uses the function MEX to build the target. On GNU/Linux 48 | % systems, the build process might fail after a warning if the compiler 49 | % version is newer than the latest version supported by MATLAB, even though 50 | % running the same MEX command on a system shell builds the target properly. 51 | % The reason is that MATLAB may extent or overwrite the environment variable 52 | % LD_LIBRARY_PATH to point to its own version of the standard libraries, 53 | % causing an incompatibility with the version of the compiler. 54 | % To solve the problem, either build the target from the shell or temporarily 55 | % overwrite the environment variable LD_LIBRARY_PATH from the MATLAB session. 56 | % 57 | % References: 58 | % Alan Murta, GPC - General Polygon Clipper library: 59 | % 60 | % 61 | % Examples: 62 | % % Check that GPC development files are installed on your system, 63 | % % or that GPC sources are present in the directory private/gpcl 64 | % setupMexPoly2tri() 65 | % 66 | % % Incompatible versions of system compiler and libraries shipped with the 67 | % % the interpreter may cause build failure. 68 | % % Try to build the target against system libraries instead of shipped ones. 69 | % ld_library_path = getenv('LD_LIBRARY_PATH') 70 | % setenv('LD_LIBRARY_PATH') 71 | % setupMexPoly2tri() 72 | % setenv('LD_LIBRARY_PATH', ld_library_path) 73 | % clear('ld_library_path') 74 | % 75 | % See also: 76 | % POLY2TRI 77 | % 78 | % Authors: 79 | % Joan Pau Beltran 80 | 81 | % Copyright (C) 2013-2016 82 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 83 | % 84 | % 85 | % This program is free software: you can redistribute it and/or modify 86 | % it under the terms of the GNU General Public License as published by 87 | % the Free Software Foundation, either version 3 of the License, or 88 | % (at your option) any later version. 89 | % 90 | % This program is distributed in the hope that it will be useful, 91 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 92 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 93 | % GNU General Public License for more details. 94 | % 95 | % You should have received a copy of the GNU General Public License 96 | % along with this program. If not, see . 97 | 98 | narginchk(0, 0); 99 | 100 | funcname = 'poly2tri'; 101 | funcpath = which(funcname); 102 | 103 | if isempty(funcpath) 104 | error('glider_toolbox:setup:NotFound', ... 105 | 'Could not find location of %s.', funcname); 106 | end 107 | 108 | prefix = fileparts(funcpath); 109 | target = fullfile(prefix, [funcname '.' mexext()]); 110 | sources = fullfile(prefix, [funcname '.c']); 111 | gpcldir = fullfile(prefix, 'gpcl'); 112 | gpclsrc = fullfile(gpcldir, 'gpc.c'); 113 | gpcl = 'gpcl'; 114 | 115 | if exist(gpcldir, 'dir') 116 | % mex -outdir mex_tools mex_tools/poly2tri.c mex_tools/gpcl/gpc.c 117 | mex('-output', target, sources, gpclsrc); 118 | else 119 | % mex -outdir mex_tools -lgpcl mex_tools/poly2tri.c 120 | mex('-output', target, ['-l' gpcl], sources); 121 | end 122 | 123 | end 124 | -------------------------------------------------------------------------------- /m/setupMexPosixtime.m: -------------------------------------------------------------------------------- 1 | function setupMexPosixtime() 2 | %SETUPMEXPOSIXTIME Build mex file for system POSIX time function POSIXTIME. 3 | % 4 | % Syntax: 5 | % SETUPMEXPOSIXTIME() 6 | % 7 | % Description: 8 | % SETUPMEXPOSIXTIME() builds a mex file implementing the function POSIXTIME, 9 | % that gets the system current POSIX time from the standard C library. 10 | % TARGET: 11 | % /path/to/posixtime.mex(a64) 12 | % SOURCES: 13 | % /path/to/posixtime.c 14 | % INCLUDES: 15 | % none 16 | % LIBRARIES: 17 | % none 18 | % 19 | % Notes: 20 | % The system time is get by the C function TIME. 21 | % 22 | % This function uses the function MEX to build the target. On GNU/Linux 23 | % systems, the build process might fail after a warning if the compiler 24 | % version is newer than the latest version supported by MATLAB, even though 25 | % running the same MEX command on a system shell builds the target properly. 26 | % The reason is that MATLAB may extent or overwrite the environment variable 27 | % LD_LIBRARY_PATH to point to its own version of the standard libraries, 28 | % causing an incompatibility with the version of the compiler. 29 | % To solve the problem, either build the target from the shell or temporarily 30 | % overwrite the environment variable LD_LIBRARY_PATH from the MATLAB session. 31 | % 32 | % Examples: 33 | % % Compile interface function for low level C function TIME. 34 | % setupMexPosixtime(); 35 | % 36 | % % Incompatible versions of system compiler and libraries shipped with the 37 | % % interpreter may cause build failure. 38 | % % Try to build the target against system libraries instead of shipped ones. 39 | % ld_library_path = getenv('LD_LIBRARY_PATH') 40 | % setenv('LD_LIBRARY_PATH') 41 | % setupMexPosixtime() 42 | % setenv('LD_LIBRARY_PATH', ld_library_path) 43 | % clear('ld_library_path') 44 | % 45 | % See also: 46 | % POSIXTIME 47 | % 48 | % Authors: 49 | % Joan Pau Beltran 50 | 51 | % Copyright (C) 2013-2016 52 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 53 | % 54 | % 55 | % This program is free software: you can redistribute it and/or modify 56 | % it under the terms of the GNU General Public License as published by 57 | % the Free Software Foundation, either version 3 of the License, or 58 | % (at your option) any later version. 59 | % 60 | % This program is distributed in the hope that it will be useful, 61 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 62 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 63 | % GNU General Public License for more details. 64 | % 65 | % You should have received a copy of the GNU General Public License 66 | % along with this program. If not, see . 67 | 68 | narginchk(0, 0); 69 | 70 | funcname = 'posixtime'; 71 | funcpath = which(funcname); 72 | 73 | if isempty(funcpath) 74 | error('glider_toolbox:setup:NotFound', ... 75 | 'Could not find location of %s.', funcname); 76 | end 77 | 78 | prefix = fileparts(funcpath); 79 | target = fullfile(prefix, [funcname '.' mexext()]); 80 | sources = fullfile(prefix, [funcname '.c']); 81 | 82 | mex('-output', target, sources); 83 | 84 | end 85 | -------------------------------------------------------------------------------- /m/setupMexSFTP.m: -------------------------------------------------------------------------------- 1 | function setupMexSFTP() 2 | %SETUPMEXSFTP Build mex file for internal functions of SFTP object methods. 3 | % 4 | % Syntax: 5 | % SETUPMEXSFTP() 6 | % 7 | % Description: 8 | % SETUPMEXSFTP() builds a mex file interface to perform operations through an 9 | % SFTP connection to a remote server using the API provided by the library 10 | % libssh. This interface is used in the implementation of the SFTP methods. 11 | % If libssh is installed from the official repositories on Debian based 12 | % distributions, the mex file is built using the following attributes: 13 | % TARGET: 14 | % /path/to/@sftp/private/mexsftp.mex(a64) 15 | % SOURCES: 16 | % /path/to/@sftp/private/mexsftp.c 17 | % INCLUDES: 18 | % none 19 | % LIBRARIES: 20 | % -l ssh 21 | % Alternatively, it is possible to build the mex file using precompiled 22 | % versions of the library for other platforms available at the web site, 23 | % or a version of the library compiled from sources locally. 24 | % The header files and the binary files should be located in the respective 25 | % directories 'libssh/include/libssh' and 'libssh/lib' in the same directory 26 | % than the mex file source. 27 | % TARGET: 28 | % /path/to/@sftp/private/mexsftp.mex(a64) 29 | % SOURCES: 30 | % /path/to/@sftp/private/mexsftp.c 31 | % INCLUDES: 32 | % -I /path/to/@sftp/private/libssh/include 33 | % LIBRARIES: 34 | % -L /path/to/@sftp/private/libssh/lib 35 | % -Wl,-rpath=$ORIGIN/libssh/lib 36 | % -l ssh 37 | % 38 | % Notes: 39 | % The libssh library provides a client API for the SFTP protocol. 40 | % The official web site of the library is: 41 | % 42 | % 43 | % On Debian based systems, the libssh library may be installed from the main 44 | % section of the official repositories running the following command as root: 45 | % apt-get install libssh-dev 46 | % 47 | % This function uses the function MEX to build the target. On GNU/Linux 48 | % systems, the build process might fail after a warning if the compiler 49 | % version is newer than the latest version supported by MATLAB, even though 50 | % running the same MEX command on a system shell builds the target properly. 51 | % The reason is that MATLAB may extend or overwrite the environment variable 52 | % LD_LIBRARY_PATH to point to its own version of the standard libraries, 53 | % causing an incompatibility with the version of the compiler. 54 | % To solve the problem, either build the target from the shell or temporarily 55 | % overwrite the environment variable LD_LIBRARY_PATH from the MATLAB session. 56 | % 57 | % References: 58 | % Aris Adamantiadis and Andreas Schneider, libssh library: 59 | % 60 | % 61 | % Examples: 62 | % % Check that libssh is properly installed on the system 63 | % % or locally in the private/libssh directory of the @sftp class. 64 | % setupMexSFTP() 65 | % 66 | % % Incompatible versions of system compiler and libraries shipped with the 67 | % % the interpreter may cause build failure. 68 | % % Try to build the target against system libraries instead of shipped ones. 69 | % ld_library_path = getenv('LD_LIBRARY_PATH') 70 | % setenv('LD_LIBRARY_PATH') 71 | % setupMexSFTP() 72 | % setenv('LD_LIBRARY_PATH', ld_library_path) 73 | % clear('ld_library_path') 74 | % 75 | % See also: 76 | % MEXSFTP 77 | % SFTP 78 | % 79 | % Authors: 80 | % Joan Pau Beltran 81 | 82 | % Copyright (C) 2014-2016 83 | % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 84 | % 85 | % 86 | % This program is free software: you can redistribute it and/or modify 87 | % it under the terms of the GNU General Public License as published by 88 | % the Free Software Foundation, either version 3 of the License, or 89 | % (at your option) any later version. 90 | % 91 | % This program is distributed in the hope that it will be useful, 92 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 93 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 94 | % GNU General Public License for more details. 95 | % 96 | % You should have received a copy of the GNU General Public License 97 | % along with this program. If not, see . 98 | 99 | narginchk(0, 0); 100 | 101 | funcname = 'mexsftp'; 102 | funcpath = which('@sftp/private/mexsftp'); 103 | 104 | if isempty(funcpath) 105 | error('glider_toolbox:setup:NotFound', ... 106 | 'Could not find location of %s.', funcname); 107 | end 108 | 109 | prefix = fileparts(funcpath); 110 | target = fullfile(prefix, [funcname '.' mexext()]); 111 | sources = fullfile(prefix, [funcname '.c']); 112 | libssh = 'ssh'; 113 | libsshdir = fullfile(prefix, 'libssh'); 114 | includedir = fullfile(libsshdir, 'include'); 115 | librarydir = fullfile(libsshdir, 'lib'); 116 | rpath = fullfile('\\\$ORIGIN', 'libssh', 'lib'); 117 | 118 | if exist(libsshdir, 'dir') 119 | mex('-output', target, ... 120 | ['-I' includedir], ... 121 | ['-L' librarydir], ... 122 | ['-l' libssh], ... 123 | ['-Wl,-rpath=' rpath], ... 124 | sources); 125 | else 126 | mex('-output', target, ['-l' libssh], sources); 127 | end 128 | 129 | end 130 | -------------------------------------------------------------------------------- /startup.m: -------------------------------------------------------------------------------- 1 | %STARTUP MATLAB startup file (kind of octaverc). 2 | 3 | 4 | addpath('m'); 5 | configGliderToolboxPath; 6 | 7 | %% External libraries 8 | [glider_toolbox_dir, ~, ~] = fileparts(mfilename('fullpath')); 9 | ext_lib_path = fullfile(glider_toolbox_dir, 'ext_lib', 'lib'); % 'octave', 'packages'); 10 | disp(strcat({'Loading libraries at '}, ext_lib_path, '...')); 11 | 12 | % snctools: NetCDF library preferences. 13 | % patched version for text attribute encoding. 14 | disp('....... mexcdf'); 15 | disp(' ==> mexnc'); 16 | addpath(fullfile(ext_lib_path, 'mexcdf', 'mexnc')); 17 | disp(' ==> snctools'); 18 | addpath(fullfile(ext_lib_path, 'mexcdf', 'snctools')); 19 | disp(' (set prefs to use java)'); 20 | setpref('SNCTOOLS', 'USE_JAVA', true); 21 | 22 | % m2html: inline html documentation generator. 23 | disp('....... m2html'); 24 | addpath(fullfile(ext_lib_path, 'm2html')); 25 | 26 | % M_Map: mapping toolbox. 27 | disp('....... m_map'); 28 | addpath(fullfile(ext_lib_path, 'm_map')); 29 | 30 | % seawater: CSIRO Sea Water Library. 31 | disp('....... seawater'); 32 | addpath(fullfile(ext_lib_path, 'seawater')); 33 | 34 | % override: overridden functions because of known bugs. 35 | %disp('....... override'); 36 | %addpath(fullfile(ext_lib_path, 'override')); 37 | 38 | disp([mfilename('fullpath'), ' loaded.']); 39 | --------------------------------------------------------------------------------