From c5d639c16ed7d62f2a19f909d4ffd2f17747d2a7 Mon Sep 17 00:00:00 2001 From: Jacques Grelet <jacques.grelet@ird.fr> Date: Thu, 3 Jan 2008 06:29:58 +0000 Subject: [PATCH] utilise la derniere version du fichier netcdf (1.4 maj) --- tsg_util/tsg_readTsgDataNetCDF.m | 222 +++++++++++++++++-------------- 1 file changed, 125 insertions(+), 97 deletions(-) diff --git a/tsg_util/tsg_readTsgDataNetCDF.m b/tsg_util/tsg_readTsgDataNetCDF.m index 227694b..f4eeee2 100644 --- a/tsg_util/tsg_readTsgDataNetCDF.m +++ b/tsg_util/tsg_readTsgDataNetCDF.m @@ -15,131 +15,159 @@ function [error] = tsg_readTsgDataNetCDF( hTsgGUI, filename) % % $Id$ +% Get the data from the application GUI +% ------------------------------------- +tsg = getappdata( hTsgGUI, 'tsg_data'); + % Open netCDF file -% ------------- -nc1 = netcdf(filename,'read'); -msg_error = 'ok'; -if isempty(nc1) - msg_error = ['TSG_GOSUD file_lecture : Open file error : ' filename]; +% ---------------- +nc = netcdf(filename,'read'); +if isempty(nc) + msg_error = ['TSG_GOSUD file_lecture : Open file error : ' filename]; + warndlg( msg_error, 'NetCDF error dialog'); + error = -1; end % Read global attributes: meta data % ---------------------------------- -tsg.PLATFORM_NAME = nc1.PLATFORM_NAME(:); -tsg.PLATFORM_WMO_NUMBER = nc1.PLATFORM_WMO_NUMBER(:); -tsg.PLATFORM_MMSI_NUMBER = nc1.PLATFORM_MMSI_NUMBER(:); -tsg.TSG_TYPE = nc1.TSG_TYPE(:); -tsg.TSG_NUMBER = nc1.TSG_NUMBER(:); -tsg.TINT_TYPE = nc1.TINT_TYPE(:); -tsg.TINT_NUMBER = nc1.TINT_NUMBER(:); -tsg.DATA_TYPE = nc1.DATA_TYPE(:); -tsg.DATA_MODE = nc1.DATA_MODE(:); -tsg.SAMPLING_PERIOD = nc1.SAMPLING_PERIOD(:); -tsg.PROCESSING_STATUS = nc1.PROCESSING_STATUS(:); -tsg.DATE_START = nc1.DATE_START(:); -tsg.DATE_END = nc1.DATE_END(:); -tsg.SOUTH_LATITUDE = nc1.SOUTH_LATITUDE; -tsg.NORTH_LATITUDE = nc1.NORTH_LATITUDE; -tsg.WEST_LONGITUDE = nc1.WEST_LONGITUDE; -tsg.EAST_LONGITUDE = nc1.EAST_LONGITUDE; -tsg.FORMAT_VERSION = nc1.FORMAT_VERSION(:); -tsg.DATE_CREATION = nc1.DATE_CREATION(:); -tsg.DATE_UPDATE = nc1.DATE_UPDATE(:); -tsg.DATA_RESTRICTIONS = nc1.DATA_RESTRICTIONS(:); -tsg.CITATION = nc1.CITATION(:); -tsg.COMMENT = nc1.COMMENT(:); -tsg.PROJECT_NAME = nc1.PROJECT_NAME(:); -tsg.PI_NAME = nc1.PI_NAME(:); -tsg.DATA_CENTRE = nc1.DATA_CENTRE(:); +tsg.PLATFORM_NAME = nc.PLATFORM_NAME(:); +tsg.SHIP_CALL_SIGN = nc.SHIP_CALL_SIGN(:); +tsg.SHIP_MMSI = nc.SHIP_MMSI(:); +tsg.TSG_TYPE = nc.TSG_TYPE(:); +tsg.TSG_NUMBER = nc.TSG_NUMBER(:); +tsg.TINT_TYPE = nc.TINT_TYPE(:); +tsg.TINT_NUMBER = nc.TINT_NUMBER(:); +tsg.DATA_TYPE = nc.DATA_TYPE(:); +tsg.DATA_MODE = nc.DATA_MODE(:); +tsg.SAMPLING_PERIOD = nc.SAMPLING_PERIOD(:); +tsg.PROCESSING_STATUS = nc.PROCESSING_STATUS(:); +tsg.DATE_START = nc.DATE_START(:); +tsg.DATE_END = nc.DATE_END(:); +tsg.SOUTH_LATX = nc.SOUTH_LATX(:); +tsg.NORTH_LATX = nc.NORTH_LATX(:); +tsg.WEST_LONX = nc.WEST_LONX(:); +tsg.EAST_LONX = nc.EAST_LONX(:); +tsg.FORMAT_VERSION = nc.FORMAT_VERSION(:); +tsg.DATE_CREATION = nc.DATE_CREATION(:); +tsg.DATE_UPDATE = nc.DATE_UPDATE(:); +tsg.DATA_RESTRICTIONS = nc.DATA_RESTRICTIONS(:); +tsg.CITATION = nc.CITATION(:); +tsg.COMMENT = nc.COMMENT(:); +tsg.PROJECT_NAME = nc.PROJECT_NAME(:); +tsg.PI_NAME = nc.PI_NAME(:); +tsg.DATA_CENTRE = nc.DATA_CENTRE(:); +tsg.DATA_ACQUISITION = nc.DATA_ACQUISITION(:); +tsg.PROCESSING_CENTRE = nc.PROCESSING_CENTRE(:); +tsg.PROCESSING_STATE = nc.PROCESSING_STATE(:); % read variables describing TSG installation % ------------------------------------------ -tsg.DEPTH_TSG = nc1{'DEPTH_TSG'}(:); -tsg.DEPTH_TSG_MIN = nc1{'DEPTH_TSG_MIN'}(:); -tsg.DEPTH_TSG_MAX = nc1{'DEPTH_TSG_MAX'}(:); -tsg.CNDC_TSG_CALCOEF = nc1{'CNDC_TSG_CALCOEF'}(:); -tsg.CNDC_TSG_LINCOEF = nc1{'CNDC_TSG_LINCOEF'}(:); -tsg.TEMP_TSG_CALCOEF = nc1{'TEMP_TSG_CALCOEF'}(:); -tsg.TEMP_TSG_LINCOEF = nc1{'TEMP_TSG_LINCOEF'}(:); +tsg.SSJT_DEPH = nc{'SSJT_DEPH'}(:); +tsg.SSJT_DEPH_MIN = nc{'SSJT_DEPH_MIN'}(:); +tsg.SSJT_DEPH_MAX = nc{'SSJT_DEPH_MAX'}(:); +tsg.CNDC_CALCOEF = nc{'CNDC_CALCOEF'}(:); +tsg.CNDC_LINCOEF = nc{'CNDC_LINCOEF'}(:); +tsg.SSJT_CALCOEF = nc{'SSJT_CALCOEF'}(:); +tsg.SSJT_LINCOEF = nc{'SSJT_LINCOEF'}(:); % read variables describing Temperature sensor at intake (TINT) installation % -------------------------------------------------------------------------- -tsg.DEPTH_TINT = nc1{'DEPTH_TINT'}(:); -tsg.DEPTH_TINT_MIN = nc1{'DEPTH_TINT_MIN'}(:); -tsg.DEPTH_TINT_MAX = nc1{'DEPTH_TINT_MAX'}(:); -tsg.TEMP_TINT_CALCOEF = nc1{'TEMP_TINT_CALCOEF'}(:); -tsg.TEMP_TINT_LINCOEF = nc1{'TEMP_TINT_LINCOEF'}(:); +tsg.SSTP_DEPH = nc{'SSTP_DEPH'}(:); +tsg.SSTP_DEPH_MIN = nc{'SSTP_DEPH_MIN'}(:); +tsg.SSTP_DEPH_MAX = nc{'SSTP_DEPH_MAX'}(:); +tsg.SSTP_CALCOEF = nc{'SSTP_CALCOEF'}(:); +tsg.SSTP_LINCOEF = nc{'SSTP_LINCOEF'}(:); % Coordinates %------------ -tsg.DATE_TSG = nc1{'DATE_TSG'}(:,:); -tsg.TIME_TSG = nc1{'TIME_TSG'}(:); -tsg.LATITUDE_TSG = nc1{'LATITUDE_TSG'}(:); -tsg.LONGITUDE_TSG = nc1{'LONGITUDE_TSG'}(:); -tsg.POSITION_TSG_QC = nc1{'POSITION_TSG_QC'}(:); -tsg.VELOCITY_TSG = nc1{'VELOCITY_TSG'}(:); +tsg.DATE = nc{'DATE'}(:,:); +tsg.DAYD = nc{'DAYD'}(:); +tsg.LATX = nc{'LATX'}(:); +tsg.LONX = nc{'LONX'}(:); +tsg.POSITION_QC = nc{'POSITION_QC'}(:); +tsg.SPDC = nc{'SPDC'}(:); +tsg.REFERENCE_DATE_TIME = nc{'REFERENCE_DATE_TIME'}(:); + +% Convert julian day with origin 1950 to Matlab datenum in memory +% --------------------------------------------------------------- +tsg.DAYD = julianToDatenum( tsg.DAYD ); % Variables holding data from the main TSG -% data series 1 +% data series 1 %----------------------------------------- -% measured variables +% measured variables %----------------------------------------- -if ~isempty('PRES') - tsg.PRES_TSG = nc1{'PRES_TSG'}(:); -end - -if ~isempty('TEMP') - tsg.TEMP_TSG = nc1{'TEMP_TSG'}(:); - tsg.TEMP_TSG_STD = nc1{'TEMP_TSG_STD'}(:); - tsg.TEMP_STD_CAL = nc1{'TEMP_STD_CAL'}(:); -end - -if ~isempty('CNDC') - tsg.CNDC_TSG = nc1{'CNDC_TSG'}(:); - tsg.CNDC_TSG_STD = nc1{'CNDC_TSG_STD'}(:); - tsg.CNDC_TSG_CAL = nc1{'CNDC_TSG_CAL'}(:); -end - -% intake temperature variable +%if isempty(tsg.PRES) + tsg.PRES = nc{'PRES'}(:); +%end + +%if isempty(tsg.SSJT) + tsg.SSJT = nc{'SSJT'}(:); + tsg.SSJT_STD = nc{'SSJT_STD'}(:); + tsg.SSJT_STD_CAL = nc{'TEMP_STD_CAL'}(:); +%end + +%if isempty(tsg.CNDC) + tsg.CNDC = nc{'CNDC'}(:); + tsg.CNDC_STD = nc{'CNDC_STD'}(:); + tsg.CNDC_CAL = nc{'CNDC_CAL'}(:); +%end + +% intake temperature variable %----------------------------------------- -tsg.TEMP = nc1{'TEMP'}(:); -tsg.TEMP_QC = nc1{'TEMP_QC'}(:); -tsg.TEMP_CAL = nc1{'TEMP_CAL'}(:); -tsg.TEMP_ADJUSTED = nc1{'TEMP_ADJUSTED'}(:); -tsg.TEMP_ADJUSTED_ERROR = nc1{'TEMP_ADJUSTED_ERROR'}(:); -tsg.TEMP_ADJUSTED_QC = nc1{'TEMP_ADJUSTED_QC'}(:); -tsg.TEMP_ADJUSTED_HIST = nc1{'HIST_TEMP_ADJUSTED'}(:); - -% derived variables +tsg.SSTP = nc{'SSTP'}(:); +tsg.SSTP_QC = nc{'SSTP_QC'}(:); +tsg.SSTP_CAL = nc{'SSTP_CAL'}(:); +tsg.SSTP_ADJUSTED = nc{'SSTP_ADJUSTED'}(:); +tsg.SSTP_ADJUSTED_ERROR = nc{'SSTP_ADJUSTED_ERROR'}(:); +tsg.SSTP_ADJUSTED_QC = nc{'SSTP_ADJUSTED_QC'}(:); +tsg.SSTP_ADJUSTED_HIST = nc{'HIST_SSTP_ADJUSTED'}(:); + +% derived variables %----------------------------------------- -tsg.PSAL = nc1{'PSAL'}(:); -tsg.PSAL_QC = nc1{'PSAL_QC'}(:); -tsg.PSAL_CAL = nc1{'PSAL_CAL'}(:); -tsg.PSAL_ADJUSTED = nc1{'PSAL_ADJUSTED'}(:); -tsg.PSAL_ADJUSTED_ERROR = nc1{'PSAL_ADJUSTED_ERROR'}(:); -tsg.PSAL_ADJUSTED_QC = nc1{'PSAL_ADJUSTED_QC'}(:); -tsg.PSAL_ADJUSTED_HIST = nc1{'HIST_PSAL_ADJUSTED'}(:); - -% data series 2 +tsg.SSPS = nc{'SSPS'}(:); +tsg.SSPS_QC = nc{'SSPS_QC'}(:); +tsg.SSPS_CAL = nc{'SSPS_CAL'}(:); +tsg.SSPS_ADJUSTED = nc{'SSPS_ADJUSTED'}(:); +tsg.SSPS_ADJUSTED_ERROR = nc{'SSPS_ADJUSTED_ERROR'}(:); +tsg.SSPS_ADJUSTED_QC = nc{'SSPS_ADJUSTED_QC'}(:); +tsg.SSPS_ADJUSTED_HIST = nc{'HIST_SSPS_ADJUSTED'}(:); + +% data series 2 %----------------------------------------- -% water samples +% water samples %----------------------------------------- -tsg.DATE_WS = nc1{'DATE_WS'}(:,:); -tsg.TIME_WS = nc1{'TIME_WS'}(:); -tsg.LATITUDE_WS = nc1{'LATITUDE_WS'}(:); -tsg.LONGITUDE_WS = nc1{'LONGITUDE_WS'}(:); -tsg.PSAL_WS = nc1{'PSAL_WS'}(:); -tsg.PSAL_WS_QC = nc1{'PSAL_WS_QC'}(:); -tsg.PSAL_WS_ANALDATE = nc1{'PSAL_WS_ANALDATE'}(:,:); -tsg.PSAL_WS_BOTTLE = nc1{'PSAL_WS_BOTTLE'}(:,:); - +tsg.DATE_WS = nc{'DATE_WS'}(:,:); +tsg.DAYD_WS = julianToDatenum(nc{'DAYD_WS'}(:)); +tsg.LATX_WS = nc{'LATX_WS'}(:); +tsg.LONX_WS = nc{'LONX_WS'}(:); +tsg.SSPS_WS = nc{'SSPS_WS'}(:); +tsg.SSPS_WS_QC = nc{'SSPS_WS_QC'}(:); +tsg.SSPS_WS_ANALDATE = nc{'SSPS_WS_ANALDATE'}(:,:); +tsg.SSPS_WS_BOTTLE = nc{'SSPS_WS_BOTTLE'}(:,:); + + +% Save the data in the application GUI +% ------------------------------------ +setappdata( hTsgGUI, 'tsg_data', tsg ); + +% Clear the Workspace +% ------------------- +clear tsgdata + +% Close the file +% -------------- %endef(nc) -close(nc) +close(nc); + +% Everything OK +% ------------- +error = 1; end -- GitLab