Commit aa23a242 authored by Achim Morschhauser's avatar Achim Morschhauser
Browse files

Merge branch 'master' into Functions

parents ca0a5c97 bf903500
......@@ -21,8 +21,8 @@
% attachment: same file
clear all
startdate = jd2000(2018, 05, 23); % HERE START DATE FOR non-online
enddate = jd2000(2018, 05, 23); % HERE END DATE FOR non-online
startdate = jd2000(2018, 07, 10); % HERE START DATE FOR non-online
enddate = jd2000(2018, 07, 10); % HERE END DATE FOR non-online
station = 'VNA1';
%station = 'WNG1';
......@@ -30,8 +30,8 @@ station = 'VNA1';
%station = 'TDC1';
%station = 'NGK0';
IAGAtype = 'P'; % preliminary data
%IAGAtype = 'Q'; % quasi definitive data
%IAGAtype = 'P'; % preliminary data
IAGAtype = 'Q'; % quasi definitive data
%IAGAtype = 'P'; % quasi definitive data
recipient = {'gfzdata@swdc234.kugi.kyoto-u.ac.jp'};
......
%% program to transfer IAGA2002-files by email to Kyoto
%
% works only from thinlink
%
% works with Q-files and P-files
% here was an error in our declination baseline for NAQ affecting data sent
% to Kyoto and Intermagnet from April 17 to 23,
% If you can send them with the similar method as the realtime data (i.e.,
% just changing the header from "R" to "Q"), Kyoto GIN will be able
% to handle them. But I need time to modify my program.
% dtudata@swdc234.kugi.kyoto-u.ac.jp
%
% header:
% tdc20120520pmin.min
%
% attachment: same file
clear all
startdate = jd2000(2016, 12, 31); % HERE START DATE FOR non-online
enddate = jd2000(2015, 12, 31); % HERE END DATE FOR non-online
station = 'VNA1';
% IAGAtype = 'P'; % preliminary data
%IAGAtype = 'Q'; % quasi definitive data
IAGAtype = 'P'; % quasi definitive data
recipient = {'gfzdata@swdc234.kugi.kyoto-u.ac.jp'};
if strcmp(station(1:3), 'VNA')
recipient = {'neumayer-geo@awi.de'
'gfzdata@swdc234.kugi.kyoto-u.ac.jp'
'Alfons.Eckstaller@awi.de'};
end %if
% recipient = {'gfzdata@swdc234.kugi.kyoto-u.ac.jp'
% 'jrgm@space.dtu.dk'};
% recipient = 'dtudata@swdc234.kugi.kyoto-u.ac.jp'; %
% recipient = 'jrgm@space.dtu.dk'; %
%recipient = 'David.Calp@NRCan-RNCan.gc.ca'
opsys = computer;
if strcmp(opsys(1:6), 'MACI64') == 1
% setup for Juergens Mac in GFZ VPN or network
path1 = '/Users/jmat/work/IAGA2002_Kyoto_transfer/';
bs = '/'; % slash
setpref('Internet','SMTP_Server','smtp.gfz-potsdam.de');
setpref('Internet','E_mail','jmat@gfz-potsdam.de');
else
diplay('operating system not recognised');
end
for i = 1:size(recipient, 1)
for idate = startdate:enddate
[year month day] = jd2date(idate);
IAGA_pathname = [path1 upper(IAGAtype) '_files' bs station(1:3) bs...
num2str(year, '%4.4d') bs];
IAGA_filename = [lower(station(1:3)) num2str(year, '%4.4d')...
num2str(month, '%2.2d') num2str(day, '%2.2d')...
lower(IAGAtype) 'min.min'];
IAGA_pathfile = [IAGA_pathname IAGA_filename]
if exist(IAGA_pathfile, 'file') == 2
% sendmail(recipients,subject,message,attachments)
sendmail(recipient{i}, IAGA_filename, '', IAGA_pathfile)
display(['sent ' IAGA_filename ' to ' recipient{i}]);
else
display(['not found: ' IAGA_filename]);
end
end %for idate
end %for i
\ No newline at end of file
%% program to transfer IAGA2002-files by email to Kyoto
%
% works only from thinlink
%
% works with Q-files and P-files
% here was an error in our declination baseline for NAQ affecting data sent
% to Kyoto and Intermagnet from April 17 to 23,
% If you can send them with the similar method as the realtime data (i.e.,
% just changing the header from "R" to "Q"), Kyoto GIN will be able
% to handle them. But I need time to modify my program.
% dtudata@swdc234.kugi.kyoto-u.ac.jp
%
% header:
% tdc20120520pmin.min
%
% attachment: same file
clear all
startdate = jd2000(2017, 01, 02); % HERE START DATE FOR non-online
enddate = jd2000(2017, 01, 02); % HERE END DATE FOR non-online
%station = 'VNA1';
%station = 'WNG1';
station = 'BFO1';
%station = 'TDC1';
%station = 'NGK0';
IAGAtype = 'P'; % preliminary data
%IAGAtype = 'Q'; % quasi definitive data
%IAGAtype = 'P'; % quasi definitive data
recipient = {'gfzdata@swdc234.kugi.kyoto-u.ac.jp'};
if strcmp(station(1:3), 'VNA')
recipient = {'neumayer-geo@awi.de'
'gfzdata@swdc234.kugi.kyoto-u.ac.jp'
'Alfons.Eckstaller@awi.de'};
end %if
% recipient = {'gfzdata@swdc234.kugi.kyoto-u.ac.jp'
% 'jrgm@space.dtu.dk'};
% recipient = 'dtudata@swdc234.kugi.kyoto-u.ac.jp'; %
% recipient = 'jrgm@space.dtu.dk'; %
%recipient = 'David.Calp@NRCan-RNCan.gc.ca'
opsys = computer;
if strcmp(opsys(1:6), 'MACI64') == 1
% setup for Juergens Mac in GFZ VPN or network
path1 = '/Users/jmat/work/IAGA2002_Kyoto_transfer/';
bs = '/'; % slash
%setpref('Internet','SMTP_Server','smtp.gfz-potsdam.de');
%setpref('Internet','E_mail','jmat@gfz-potsdam.de');
setpref('Internet','SMTP_Server','smtp.gfz-potsdam.de');
setpref('Internet','E_mail','tornow@gfz-potsdam.de');
elseif strcmp(opsys(1:2), 'PC') == 1
path1 = 'O:\jmat\IAGA2002_Kyoto_transfer\';
bs = '\'; % slash
setpref('Internet','SMTP_Server','smtp.gfz-potsdam.de');
setpref('Internet','E_mail','jmat@gfz-potsdam.de');
else
diplay('operating system not recognised');
end
for i = 1:size(recipient, 1)
for idate = startdate:enddate
[year month day] = jd2date(idate);
IAGA_pathname = [path1 upper(IAGAtype) '_files' bs station(1:3) bs...
num2str(year, '%4.4d') bs];
IAGA_filename = [lower(station(1:3)) num2str(year, '%4.4d')...
num2str(month, '%2.2d') num2str(day, '%2.2d')...
lower(IAGAtype) 'min.min'];
IAGA_pathfile = [IAGA_pathname IAGA_filename]
if exist(IAGA_pathfile, 'file') == 2
% sendmail(recipients,subject,message,attachments)
sendmail(recipient{i}, IAGA_filename, '', IAGA_pathfile)
display(['sent ' IAGA_filename ' to ' recipient{i}]);
else
display(['not found: ' IAGA_filename]);
end
end %for idate
end %for i
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
% datalogger code 'a' maybe for tabulated values
% datalogger code 'b' maybe for photographic paper
% datalogger code 'c' for PCD
% datalogger code 'd' for ADAM module
% datalogger code 'f' for Tromsø (not yet)
%
% 2013-04-15 jrgm:
% make function calcualte_baseline.m fit for Matlab2013 cdfread:
% %informcdf.Variables{i,3},1 contains the length of the array
%
% make function calcualte_ime_error_absolutes.m fit for Matlab2013 cdfread:
% %informcdf.Variables{i,3},1 contains the length of the array
clear all
close all
figure
station = 'NGK0g'; %'NGK0g'; % c or d or g or s for datalogger
ppmsource = 'c'; % 's' for spreadsheet, 'c' for cdf
tempsource = 'c'; % c for cdf
temp_correct = 'y'; % apply temp-correction function to variations 'y'
apply_time_lag = 'y'; %reads from raw1(K61)
find_time_error = 'n';
timeshift_array = [-300:1:300]';
number_DI = 1000; % read in all DI-measurements for this year
number_DI = 5; % read in the last x measurements in this year
number_DI = 0; % use date range from below
year = 2016;
start_mmdd = '0127';
end___mmdd = '0127';
return_array = []; %returnes baseliens etc from function
opsys = computer;
% if strcmp(opsys(1:2), 'GL') == 1 %removed because XLS-files can only be
% processed on Windows systems
% path1 = '/nfs/magobs/';
% bs = '/'; % slash
% else
if strcmp(opsys(1:2), 'PC') == 1
path1 = 'Y:';
bs = '\'; % backslash
else
diplay('operating system not recognised');
end
path_DI = [path1 bs 'jmat' bs '0DI_measurements' bs 'DI_' ...
station(1:3) ...
num2str(year, '%4.4d') bs];
path_cdf = [path1 bs 'jmat' bs station(1:4) bs 'cdf' bs];
%month = 1; removed 27/2-2012
%day = 7;
% % START Identify and convert Achims GFZ-DI-schemes
% % with name e.g. ng0_140102.xls
% %
% %
% if strcmp(station(1:3), 'NGK') || strcmp(station(1:3), 'WNG') ...
% || strcmp(station(1:3), 'VRE') || strcmp(station(1:3), 'SHE') ...
% || strcmp(station(1:3), 'PAG') || strcmp(station(1:3), 'SUR') ...
% || strcmp(station(1:3), 'ODE') || strcmp(station(1:3), 'KMH') ...
% || strcmp(station(1:3), 'YAK') || strcmp(station(1:3), 'MGD') ...
% || strcmp(station(1:3), 'ABG') || strcmp(station(1:3), 'HYD') ...
% || strcmp(station(1:3), 'PNL') || strcmp(station(1:3), 'SMA') ...
% || strcmp(station(1:3), 'LOC') || strcmp(station(1:3), 'PET')
% filename_criterion = [path_DI lower(station(1:2)) station(4) ...
% '_' num2str(year-2000, '%2.2d') '*.xls'];
% filename_length = 14;
%
%
% % find all files in directory that satisfy criterion
% B = dir(filename_criterion);
% C = struct2cell(B);
%
% %remove filernames with wrong length, this is because I add comment to file
% %name as indicator for bad measuremmtns and this changes length of filename
% for i = 1:size(C, 2)
% length_here = size(char(C{1,i}), 2);
% if length_here == filename_length
% D(i) = 1;
% else
% D(i) = 0;
% end
% end
% C = C(:,D == 1);
% filenames = char(C{1,:});
% clear D
%
% % I skip this part here: remove filenames that have '0' or '1' at 'end-11'
%
% % reduce number of DI-measurements to selected date range or number
% if number_DI ~= 1000
% if number_DI == 0
% for i = 1:size(C, 2)
% characters_here = char(C{1,i});
% if str2num(characters_here(end-7:end-4)) >= ...
% str2num(start_mmdd) &&...
% str2num(characters_here(end-7:end-4)) <= ...
% str2num(end___mmdd)
% D(i) = 1;
% else
% D(i) = 0;
% end
%
% end
% C = C(:,D == 1);
% filenames = char(C{1,:});
% clear D
% end
% else
% filenames1 = filenames;
% filenames = filenames1(end - number_DI+1:end,:);
% end
%
% % call function to convert
% for i = 1:size(filenames, 1)
% DI_file = [filenames(i,:)];
% if exist([path_DI DI_file], 'file')
% % convert
% [return_string] = ...
% calculate_baseline_convert_GFZ_form(station, path_DI, DI_file);
% % move GFZ-files to directory 'converted_GFZ'
% if exist([path_DI 'converted_GFZ'],'dir') == 0
% mkdir([path_DI 'converted_GFZ'])
% end
% for j = 1:size(filenames, 1)
% % incode here moving of filenames to 'conver...
% % folder!!!!!!!!!!!!!
% end
% end
% end %i
% clear B C D filenames filenames1 filename
%
% end
% %
% %
% %
% % END Identify and convert Achims GFZ-DI-schemes
%
%
%read in filenames for DI-files from directory, remove unrelevant filenames
%from list
if strcmp(station(1:3), 'TDC') || strcmp(station(1:3), 'VNA') ...
|| strcmp(station(1:3), 'NGK') || strcmp(station(1:3), 'WNG') ...
|| strcmp(station(1:3), 'TTB')
filename_criterion = [path_DI 'DI_' station(1:3) '_'...
num2str(year, '%4.4d') '*.xls'];
filename_length = 23;
% elseif strcmp(station(1:3), 'WNG')
%
% filename_criterion = [path_DI 'DI_' station(1:3) '0_'...
% num2str(year-2000, '%2.2d') '*.xls'];
% filename_length = 22;
else
filename_criterion = [path_DI '*.xls'];
filename_length = 12;
end
B = dir(filename_criterion);
C = struct2cell(B);
for i = 1:size(C, 2) %remove filernames with wrong length
length_here = size(char(C{1,i}), 2);
if length_here == filename_length
D(i) = 1;
else
D(i) = 0;
end
end
C = C(:,D == 1);
filenames = char(C{1,:});
clear D
for i = 1:size(C, 2) %remove filenames that have '0' or '1' at 'end-11'
characters_here = char(C{1,i});
if strcmp(characters_here(end-11), '0') || ...
strcmp(characters_here(end-11), '1')
D(i) = 1;
else
D(i) = 0;
end
end
C = C(:,D == 1);
filenames = char(C{1,:});
clear D
% reduce number of DI-measurements
if number_DI ~= 1000
if number_DI == 0
for i = 1:size(C, 2) %remove filenames that have '0' or '1' at 'end-11'
characters_here = char(C{1,i});
if str2num(characters_here(end-11:end-8)) >= ...
str2num(start_mmdd) &&...
str2num(characters_here(end-11:end-8)) <= ...
str2num(end___mmdd)
D(i) = 1;
else
D(i) = 0;
end
end
C = C(:,D == 1);
filenames = char(C{1,:});
clear D
end
else
filenames1 = filenames;
filenames = filenames1(end - number_DI+1:end,:);
end
%
%
% call function for list of filenames
%
%
for i = 1:size(filenames, 1)
DI_file = [path_DI filenames(i,:)];
cdf_file = [path_cdf station(1:4) '_' num2str(year, '%4.4d')...
filenames(i,end-11:end-8) '.cdf'];
if exist(DI_file, 'file')
if strcmp(find_time_error, 'y')
[return_string] = ...
calculate_time_error_absolutes(DI_file, cdf_file, station,...
ppmsource, tempsource, temp_correct, timeshift_array);
else
[return_string] = ...
calculate_baselines(DI_file, cdf_file, station,...
ppmsource, tempsource, temp_correct, apply_time_lag);
return_string = char(return_string{1});
end
end
return_array = [return_array; return_string]
end %i
save('recent-DI', 'return_array')
% datalogger code 'a' maybe for tabulated values
% datalogger code 'b' maybe for photographic paper
% datalogger code 'c' for PCD
% datalogger code 'd' for ADAM module
% datalogger code 'g' for GFZ 0.5 Hz
% datalogger code 's' for seismic
% datalogger code 'l' for LEMI
% datalogger code 'f' for Flare
%
% 2013-04-15 jrgm:
% make function calcualte_baseline.m fit for Matlab2013 cdfread:
% %informcdf.Variables{i,3},1 contains the length of the array
%
% make function calcualte_ime_error_absolutes.m fit for Matlab2013 cdfread:
% %informcdf.Variables{i,3},1 contains the length of the array
clear all
close all
figure
station = 'WNG1g'; %'NGK0g'; % c or d or g or s or l for datalogger
ppmsource = 'c'; % 's' for spreadsheet, 'c' for cdf
tempsource = 'c'; % c for cdf
temp_correct = 'y'; % apply temp-correction function to variations 'y'
apply_time_lag = 'y'; %reads from raw1(K61)
find_time_error = 'n';
timeshift_array = [-300:1:300]';
number_DI = 1000; % read in all DI-measurements for this year
number_DI = 5; % read in the last x measurements in this year
number_DI = 0; % use date range from below
year = 2016;
start_mmdd = '0106';
end___mmdd = '0124';
return_array = []; %returnes baseliens etc from function
opsys = computer;
% if strcmp(opsys(1:2), 'GL') == 1 %removed because XLS-files can only be
% processed on Windows systems
% path1 = '/nfs/magobs/';
% bs = '/'; % slash
% else
if strcmp(opsys(1:2), 'PC') == 1
path1 = 'Y:';
bs = '\'; % backslash
else
diplay('operating system not recognised');
end
path_DI = [path1 bs 'BPDATA' bs 'DI_' station(1:3) ...
num2str(year, '%4.4d') bs];
path_cdf = [path1 bs 'laptop_data' bs station(1:4) bs 'cdf' bs];
if strcmp(pwd, 'Y:\jmat\0programme_win')
path_DI = [path1 bs 'jmat' bs '0DI_measurements' bs 'DI_' ...
station(1:3) ...
num2str(year, '%4.4d') bs];
path_cdf = [path1 bs 'jmat' bs station(1:4) bs 'cdf' bs];
end
%month = 1; removed 27/2-2012
%day = 7;
% % START Identify and convert Achims GFZ-DI-schemes
% % with name e.g. ng0_140102.xls
% %
% %
% if strcmp(station(1:3), 'NGK') || strcmp(station(1:3), 'WNG') ...
% || strcmp(station(1:3), 'VRE') || strcmp(station(1:3), 'SHE') ...
% || strcmp(station(1:3), 'PAG') || strcmp(station(1:3), 'SUR') ...
% || strcmp(station(1:3), 'ODE') || strcmp(station(1:3), 'KMH') ...
% || strcmp(station(1:3), 'YAK') || strcmp(station(1:3), 'MGD') ...
% || strcmp(station(1:3), 'ABG') || strcmp(station(1:3), 'HYD') ...
% || strcmp(station(1:3), 'PNL') || strcmp(station(1:3), 'SMA') ...
% || strcmp(station(1:3), 'LOC') || strcmp(station(1:3), 'PET')
% filename_criterion = [path_DI lower(station(1:2)) station(4) ...
% '_' num2str(year-2000, '%2.2d') '*.xls'];
% filename_length = 14;
%
%
% % find all files in directory that satisfy criterion
% B = dir(filename_criterion);
% C = struct2cell(B);
%
% %remove filernames with wrong length, this is because I add comment to file
% %name as indicator for bad measuremmtns and this changes length of filename
% for i = 1:size(C, 2)
% length_here = size(char(C{1,i}), 2);
% if length_here == filename_length
% D(i) = 1;
% else
% D(i) = 0;
% end
% end
% C = C(:,D == 1);
% filenames = char(C{1,:});
% clear D
%
% % I skip this part here: remove filenames that have '0' or '1' at 'end-11'
%
% % reduce number of DI-measurements to selected date range or number
% if number_DI ~= 1000
% if number_DI == 0
% for i = 1:size(C, 2)
% characters_here = char(C{1,i});
% if str2num(characters_here(end-7:end-4)) >= ...
% str2num(start_mmdd) &&...
% str2num(characters_here(end-7:end-4)) <= ...
% str2num(end___mmdd)
% D(i) = 1;
% else
% D(i) = 0;
% end
%
% end
% C = C(:,D == 1);
% filenames = char(C{1,:});
% clear D
% end
% else
% filenames1 = filenames;
% filenames = filenames1(end - number_DI+1:end,:);
% end
%
% % call function to convert
% for i = 1:size(filenames, 1)
% DI_file = [filenames(i,:)];
% if exist([path_DI DI_file], 'file')
% % convert
% [return_string] = ...
% calculate_baseline_convert_GFZ_form(station, path_DI, DI_file);
% % move GFZ-files to directory 'converted_GFZ'
% if exist([path_DI 'converted_GFZ'],'dir') == 0
% mkdir([path_DI 'converted_GFZ'])
% end
% for j = 1:size(filenames, 1)
% % incode here moving of filenames to 'conver...