Skip to content

Commit

Permalink
Add function with switch for the two sea ice time series
Browse files Browse the repository at this point in the history
  • Loading branch information
imab4bsh committed May 5, 2021
1 parent 770447e commit 885f0db
Show file tree
Hide file tree
Showing 5 changed files with 604 additions and 128 deletions.
30 changes: 30 additions & 0 deletions ForRomain.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
% In the excel file Romain send me, I created another sheet for extracting
% the date in the format I needed it. I saved it as Text separated by Tabs.
% then I had to replace commas by dots using a text editor.
% Finally, I imported the data using the matlab import wizard (saved script
% as ImportExcelData)
clear variables;
load listromain2
datev=[YEAR MONTH DAY];
lon=LONGITUDE;
lat=LATITUDE;
sat_dir='\\win.bsh.de\root$\Standard\Hamburg\Homes\Homes00\bm2286\ICE\ice_im\';

warning('off','MATLAB:structOnObject')
f=find(abs(lat)>60);
for i=1:numel(f)
disp([num2str(i) '/' num2str(numel(f))])
%[pix_ice(f(i)),dist_ice(f(i)),sat_ice(f(i))]=metaprof_satice(datev(f(i),:),lon(f(i)),lat(f(i)),sat_dir);
[pix_ice(f(i)),dist_ice(f(i)),sat_ice(f(i))]=metaprof_satice_src(datev(f(i),:),lon(f(i)),lat(f(i)),sat_dir,'RT');
end
save extr_romain3.mat

%%

for i=1:numel(sat_ice)
if isempty(getfield(pix_ice,{i},'sic'))==0
sic(i)=getfield(pix_ice,{i},'sic');
else
sic(i)=NaN;
end
end
48 changes: 48 additions & 0 deletions ImportExcelData.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
%% Import data from text file
% Script for importing data from the following text file:
%
% filename: \\win.bsh.de\root$\Standard\Hamburg\Homes\Homes00\bm2286\ICE\202105_Romain\CompleteExport_GPS_fix0_20210416.txt
%
% Auto-generated by MATLAB on 05-May-2021 07:03:18

%% Setup the Import Options and import the data
opts = delimitedTextImportOptions("NumVariables", 14);

% Specify range and delimiter
opts.DataLines = [2, Inf];
opts.Delimiter = "\t";

% Specify column names and types
opts.VariableNames = ["PLATFORM_CODE", "CV_NUMBER", "LONGITUDE", "LATITUDE", "STATION_DATE", "PLATFORM_TYPE", "DAC", "FIRMWARE_VERSION", "TECH_FLAG_ICEDETECTION_NUMBER", "ICEALGORITHMACTIVATED_LOGICAL", "TRANSMISSIONDELAYED_NUMBER", "YEAR", "MONTH", "DAY"];
opts.VariableTypes = ["double", "double", "double", "double", "datetime", "categorical", "categorical", "categorical", "string", "string", "string", "double", "double", "double"];

% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";

% Specify variable properties
opts = setvaropts(opts, ["TECH_FLAG_ICEDETECTION_NUMBER", "ICEALGORITHMACTIVATED_LOGICAL", "TRANSMISSIONDELAYED_NUMBER"], "WhitespaceRule", "preserve");
opts = setvaropts(opts, ["PLATFORM_TYPE", "DAC", "FIRMWARE_VERSION", "TECH_FLAG_ICEDETECTION_NUMBER", "ICEALGORITHMACTIVATED_LOGICAL", "TRANSMISSIONDELAYED_NUMBER"], "EmptyFieldRule", "auto");
opts = setvaropts(opts, "STATION_DATE", "InputFormat", "");

% Import the data
tbl = readtable("\\win.bsh.de\root$\Standard\Hamburg\Homes\Homes00\bm2286\ICE\202105_Romain\CompleteExport_GPS_fix0_20210416.txt", opts);

%% Convert to output type
PLATFORM_CODE = tbl.PLATFORM_CODE;
CV_NUMBER = tbl.CV_NUMBER;
LONGITUDE = tbl.LONGITUDE;
LATITUDE = tbl.LATITUDE;
STATION_DATE = tbl.STATION_DATE;
PLATFORM_TYPE = tbl.PLATFORM_TYPE;
DAC = tbl.DAC;
FIRMWARE_VERSION = tbl.FIRMWARE_VERSION;
TECH_FLAG_ICEDETECTION_NUMBER = tbl.TECH_FLAG_ICEDETECTION_NUMBER;
ICEALGORITHMACTIVATED_LOGICAL = tbl.ICEALGORITHMACTIVATED_LOGICAL;
TRANSMISSIONDELAYED_NUMBER = tbl.TRANSMISSIONDELAYED_NUMBER;
YEAR = tbl.YEAR;
MONTH = tbl.MONTH;
DAY = tbl.DAY;

%% Clear temporary variables
clear opts tbl
Loading

0 comments on commit 885f0db

Please sign in to comment.