tdiff --git a/matlab/import_php_file.m b/matlab/import_php_file.m index 0dfc2c1..36c71c2 100644 --- a/matlab/import_php_file.m +++ b/matlab/import_php_file.m @@ -115,10 +115,10 @@ end - cosmo - front and backend for Markov-Chain Monte Carlo inversion of cosmogenic nuclide concentrations
(HTM) git clone git://src.adamsgaard.dk/cosmo
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 1df2026ff8d7604249f6dc7b4b4ef38d5a1cb2c0
(DIR) parent 602c4a22e826a9710597c6518d86d7d833a328d5
(HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Tue, 17 Nov 2015 16:35:49 +0100
diff --git a/matlab/import_php_file.m b/matlab/import_php_file.m
index 0dfc2c1..36c71c2 100644
--- a/matlab/import_php_file.m
+++ b/matlab/import_php_file.m
@@ -115,10 +115,10 @@ end
% rows with numbers, check that range matches values in for loop l. 68 and
% the list below
-rawNumericColumns = raw(:, [6:28, 30:31]);
+rawNumericColumns = raw(:, [6:32, 34:36]);
% rows with strings
-rawCellColumns = raw(:, [1:5, 29]);
+rawCellColumns = raw(:, [1:5, 33]);
%% Allocate imported array to column variable names
@@ -141,19 +141,24 @@ be_zobs = cell2mat(rawNumericColumns(:, 9)); % 14
al_zobs = cell2mat(rawNumericColumns(:, 10)); % 15
c_zobs = cell2mat(rawNumericColumns(:, 11)); % 16
ne_zobs = cell2mat(rawNumericColumns(:, 12)); % 17
-be_prod_muon = cell2mat(rawNumericColumns(:, 13)); % 18
-al_prod_muon = cell2mat(rawNumericColumns(:, 14)); % 19
-c_prod_muon = cell2mat(rawNumericColumns(:, 15)); % 20
-ne_prod_muon = cell2mat(rawNumericColumns(:, 16)); % 21
-rock_density = cell2mat(rawNumericColumns(:, 17)); % 22
-epsilon_gla_min = cell2mat(rawNumericColumns(:, 18)); % 23
-epsilon_gla_max = cell2mat(rawNumericColumns(:, 19)); % 24
-epsilon_int_min = cell2mat(rawNumericColumns(:, 20)); % 25
-epsilon_int_max = cell2mat(rawNumericColumns(:, 21)); % 26
-t_degla_min = cell2mat(rawNumericColumns(:, 22)); % 27
-t_degla_max = cell2mat(rawNumericColumns(:, 23)); % 28
-record = rawCellColumns(:, 6); % 29
-record_threshold_min = cell2mat(rawNumericColumns(:, 24)); % 30
-record_threshold_max = cell2mat(rawNumericColumns(:, 25)); % 31
+be_prod_muon = cell2mat(rawNumericColumns(:, 13)); % 18
+al_prod_muon = cell2mat(rawNumericColumns(:, 14)); % 19
+c_prod_muon = cell2mat(rawNumericColumns(:, 15)); % 20
+ne_prod_muon = cell2mat(rawNumericColumns(:, 16)); % 21
+be_prod_spall = cell2mat(rawNumericColumns(:, 17)); % 22
+al_prod_spall = cell2mat(rawNumericColumns(:, 18)); % 23
+c_prod_spall = cell2mat(rawNumericColumns(:, 19)); % 24
+ne_prod_spall = cell2mat(rawNumericColumns(:, 20)); % 25
+rock_density = cell2mat(rawNumericColumns(:, 21)); % 26
+epsilon_gla_min = cell2mat(rawNumericColumns(:, 22)); % 27
+epsilon_gla_max = cell2mat(rawNumericColumns(:, 23)); % 28
+epsilon_int_min = cell2mat(rawNumericColumns(:, 24)); % 29
+epsilon_int_max = cell2mat(rawNumericColumns(:, 25)); % 30
+t_degla_min = cell2mat(rawNumericColumns(:, 26)); % 31
+t_degla_max = cell2mat(rawNumericColumns(:, 27)); % 32
+record = rawCellColumns(:, 6); % 33
+record_threshold_min = cell2mat(rawNumericColumns(:, 28)); % 34
+record_threshold_max = cell2mat(rawNumericColumns(:, 29)); % 35
+nwalkers = cell2mat(rawNumericColumns(:, 30)); % 36
diff --git a/matlab/import_php_file.m~ b/matlab/import_php_file.m~
new file mode 100644
index 0000000..b53897b
--- /dev/null
+++ b/matlab/import_php_file.m~
@@ -0,0 +1,163 @@
+function [sample_id, name, email, ...
+ lat, long, ...
+ be_conc, al_conc, c_conc, ne_conc, ...
+ be_uncer, al_uncer, c_uncer, ne_uncer, ...
+ be_zobs, al_zobs, c_zobs, ne_zobs, ...
+ be_prod_muon, al_prod_muon, c_prod_muon, ne_prod_muon, ...
+ be_prod_spall, al_prod_spall, c_prod_spall, ne_prod_spall, ...
+ rock_density, ...
+ epsilon_gla_min, epsilon_gla_max, ...
+ epsilon_int_min, epsilon_int_max, ...
+ t_degla_min, t_degla_max, ...
+ record, record_threshold_min, record_threshold_max, ...
+ nwalkers] = ...
+ import_php_file(filename, startRow, endRow)
+
+%% import_php_file.m
+% Automatically generated using the `uiimport` tool in Matlab.
+% If the output format in "uploadhistory.php" is changed, update this file
+% accordingly.
+% All columns are initially read as strings. Some of the columns (specified
+% by the col vector) are converted to numbers.
+
+%IMPORTFILE Import numeric data from a text file as column vectors.
+% [SAMPLEID,NAME,EMAIL,LAT,LONG,BE_CONC,AL_CONC,C_CONC,NE_CONC,BE_UNCER,AL_UNCER,C_UNCER,NE_UNCER,BE_ZOBS,AL_ZOBS,C_ZOBS,NE_ZOBS,BE_PROD,AL_PROD,C_PROD,NE_PROD,ROCK_DENSITY,EPSILON_GLA_MIN,EPSILON_GLA_MAX,EPSILON_INT_MIN,EPSILON_INT_MAX,T_DEGLA,T_DEGLA_UNCER,RECORD,RECORD_THRESHOLD_MIN,RECORD_THRESHOLD_MAX]
+% = IMPORTFILE(FILENAME) Reads data from text file FILENAME for the
+% default selection.
+%
+% [SAMPLEID,NAME,EMAIL,LAT,LONG,BE_CONC,AL_CONC,C_CONC,NE_CONC,BE_UNCER,AL_UNCER,C_UNCER,NE_UNCER,BE_ZOBS,AL_ZOBS,C_ZOBS,NE_ZOBS,BE_PROD,AL_PROD,C_PROD,NE_PROD,ROCK_DENSITY,EPSILON_GLA_MIN,EPSILON_GLA_MAX,EPSILON_INT_MIN,EPSILON_INT_MAX,T_DEGLA,T_DEGLA_UNCER,RECORD,RECORD_THRESHOLD_MIN,RECORD_THRESHOLD_MAX]
+% = IMPORTFILE(FILENAME, STARTROW, ENDROW) Reads data from rows STARTROW
+% through ENDROW of text file FILENAME.
+%
+% Example:
+% [sampleid,name,email,lat,long,be_conc,al_conc,c_conc,ne_conc,be_uncer,al_uncer,c_uncer,ne_uncer,be_zobs,al_zobs,c_zobs,ne_zobs,be_prod,al_prod,c_prod,ne_prod,rock_density,epsilon_gla_min,epsilon_gla_max,epsilon_int_min,epsilon_int_max,t_degla,t_degla_uncer,record,record_threshold_min,record_threshold_max]
+% = importfile('cosmo_pgpzvt',1, 1);
+%
+% See also TEXTSCAN.
+
+% Auto-generated by MATLAB on 2015/08/24 12:47:00
+
+%% Initialize variables.
+delimiter = '\t';
+if nargin<=2
+ startRow = 1;
+ endRow = inf;
+end
+
+%% Read columns of data as strings:
+% For more information, see the TEXTSCAN documentation.
+%formatSpec = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%[^\n\r]';
+formatSpec = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%[^\n\r]';
+
+%% Open the text file.
+fileID = fopen(filename,'r');
+
+%% Read columns of data according to format string.
+% This call is based on the structure of the file used to generate this
+% code. If an error occurs for a different file, try regenerating the code
+% from the Import Tool.
+dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'HeaderLines', startRow(1)-1, 'ReturnOnError', false);
+for block=2:length(startRow)
+ frewind(fileID);
+ dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', delimiter, 'HeaderLines', startRow(block)-1, 'ReturnOnError', false);
+ for col=1:length(dataArray)
+ dataArray{col} = [dataArray{col};dataArrayBlock{col}];
+ end
+end
+
+%% Close the text file.
+fclose(fileID);
+
+%% Convert the contents of columns containing numeric strings to numbers.
+% Replace non-numeric strings with NaN.
+raw = repmat({''},length(dataArray{1}),length(dataArray)-1);
+for col=1:length(dataArray)-1
+ raw(1:length(dataArray{col}),col) = dataArray{col};
+end
+numericData = NaN(size(dataArray{1},1),size(dataArray,2));
+
+% the columns in col are numeric
+%for col=[6,7,8,9,10,11,12,13,18,19,20,21,22,23,24,26,27]
+for col=[6:32, 34:36]
+ % Converts strings in the input cell array to numbers. Replaced non-numeric
+ % strings with NaN.
+ rawData = dataArray{col};
+ for row=1:size(rawData, 1);
+ % Create a regular expression to detect and remove non-numeric prefixes and
+ % suffixes.
+ regexstr = '(?<prefix>.*?)(?<numbers>([-]*(\d+[\,]*)+[\.]{0,1}\d*[eEdD]{0,1}[-+]*\d*[i]{0,1})|([-]*(\d+[\,]*)*[\.]{1,1}\d+[eEdD]{0,1}[-+]*\d*[i]{0,1}))(?<suffix>.*)';
+ try
+ result = regexp(rawData{row}, regexstr, 'names');
+ numbers = result.numbers;
+
+ % Detected commas in non-thousand locations.
+ invalidThousandsSeparator = false;
+ if any(numbers==',');
+ thousandsRegExp = '^\d+?(\,\d{3})*\.{0,1}\d*$';
+ if isempty(regexp(thousandsRegExp, ',', 'once'));
+ numbers = NaN;
+ invalidThousandsSeparator = true;
+ end
+ end
+ % Convert numeric strings to numbers.
+ if ~invalidThousandsSeparator;
+ numbers = textscan(strrep(numbers, ',', ''), '%f');
+ numericData(row, col) = numbers{1};
+ raw{row, col} = numbers{1};
+ end
+ catch me
+ end
+ end
+end
+
+
+%% Split data into numeric and cell columns.
+
+% rows with numbers, check that range matches values in for loop l. 68 and
+% the list below
+rawNumericColumns = raw(:, [6:28, 30:31]);
+
+% rows with strings
+rawCellColumns = raw(:, [1:5, 29]);
+
+
+%% Allocate imported array to column variable names
+% use rawCellColumns(:, i) for text fields and
+% cell2mat(rawNumericColumns(:, i)) for numeric fields
+sample_id = rawCellColumns(:, 1); % 1
+name = rawCellColumns(:, 2); % 2
+email = rawCellColumns(:, 3); % 3
+lat = rawCellColumns(:, 4); % 4
+long = rawCellColumns(:, 5); % 5
+be_conc = cell2mat(rawNumericColumns(:, 1)); % 6
+al_conc = cell2mat(rawNumericColumns(:, 2)); % 7
+c_conc = cell2mat(rawNumericColumns(:, 3)); % 8
+ne_conc = cell2mat(rawNumericColumns(:, 4)); % 9
+be_uncer = cell2mat(rawNumericColumns(:, 5)); % 10
+al_uncer = cell2mat(rawNumericColumns(:, 6)); % 11
+c_uncer = cell2mat(rawNumericColumns(:, 7)); % 12
+ne_uncer = cell2mat(rawNumericColumns(:, 8)); % 13
+be_zobs = cell2mat(rawNumericColumns(:, 9)); % 14
+al_zobs = cell2mat(rawNumericColumns(:, 10)); % 15
+c_zobs = cell2mat(rawNumericColumns(:, 11)); % 16
+ne_zobs = cell2mat(rawNumericColumns(:, 12)); % 17
+be_prod_muon = cell2mat(rawNumericColumns(:, 13)); % 18
+al_prod_muon = cell2mat(rawNumericColumns(:, 14)); % 19
+c_prod_muon = cell2mat(rawNumericColumns(:, 15)); % 20
+ne_prod_muon = cell2mat(rawNumericColumns(:, 16)); % 21
+be_prod_spall = cell2mat(rawNumericColumns(:, 13)); % 18
+al_prod_spall = cell2mat(rawNumericColumns(:, 14)); % 19
+c_prod_spall = cell2mat(rawNumericColumns(:, 15)); % 20
+ne_prod_spall = cell2mat(rawNumericColumns(:, 16)); % 21
+rock_density = cell2mat(rawNumericColumns(:, 17)); % 22
+epsilon_gla_min = cell2mat(rawNumericColumns(:, 18)); % 23
+epsilon_gla_max = cell2mat(rawNumericColumns(:, 19)); % 24
+epsilon_int_min = cell2mat(rawNumericColumns(:, 20)); % 25
+epsilon_int_max = cell2mat(rawNumericColumns(:, 21)); % 26
+t_degla_min = cell2mat(rawNumericColumns(:, 22)); % 27
+t_degla_max = cell2mat(rawNumericColumns(:, 23)); % 28
+record = rawCellColumns(:, 6); % 29
+record_threshold_min = cell2mat(rawNumericColumns(:, 24)); % 30
+record_threshold_max = cell2mat(rawNumericColumns(:, 25)); % 31
+
+
diff --git a/matlab/output/.DS_Store b/matlab/output/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/matlab/output/.DS_Store differ
Diff is too large, output suppressed.