-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_standard_data.m
70 lines (63 loc) · 2.68 KB
/
make_standard_data.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function [out_name,out_data] = make_standard_data...
(filedata,geodata,timedata,nodata,header,dates,GHI,DNI,DHI,others)
%MAKE_STANDARD_DATA Creates a MATLAB structure that saves the information
%required for the next modules in a standard format.
% INPUT:
% filedata: Info for identification and creation of the output file name
% geodata: Geographical localization of the station
% timedata: Info related with the time reference of the station
% nodata: No data value
% header: Headers of the variables included in the data matrix
% dates: Date array of the data (same lenght of the variables data arrays)
% GHI: Global Horizontal Irradiance data array
% DNI: Direct Normal Irradiance data array
% DHI: Diffuse Horizontal Irradiance data array
% others: others variables data matrix
%
% OUTPUT:
% name_out: Name of the output file
% data: Standard structure with the data
%
% Format of the output file name: LOCAL-OWN-NN-yyyy
% LOCAL: 5 chars of the locality
% OWN : 3 chars of the owner
% NN : 2 chars station number (same locality and owner)
% yyyy : 4 chars year of the data (ID)
%
% - L. Ramírez (April 2013) Initial version
% - L. Ramírez (July 2014) Update
% - L. Ramírez (May 2015) Update
% - F. Mendoza (February 2017) Update
%% Data structure outline
% data.filedata.own: owner
% data.filedata.loc: location
% data.filedata.name: name for the output information
% data.filedata.num: number of the station
% data.filedata.ID: year of the data stored in the structure (identifier)
% data.geodata.lat: latitude [ºN]
% data.geodata.lon: longitude[ºE]
% data.geodata.alt: altitude a.s.l. [m]
% data.timedata.timezone: time reference in which data is acquired
% data.timedata.stamp: 0 ini int / 0.5 centre int / 1 end int
% data.timedata.num_obs: number of observations per hour
% data.nodata: no data value
% data.header: headers of the matrix columns
% YYYY MM DD HH mm ss GHI DNI DHI
% data.mat: matrix of data
%% Structure creation
filedata.own = string_chars(filedata.own,3,'0'); % Function
filedata.loc = string_chars(filedata.loc,5,'0');
filedata.name = [filedata.loc '-' filedata.own '-' filedata.num '-' filedata.ID];
[filedata.num,~] = string_chars_num(filedata.num,2); % Function
filedata.ID = string_chars(filedata.ID,4,'0');
data.filedata = filedata;
data.geodata = geodata;
data.timedata = timedata;
data.nodata = nodata;
data.header = header;
matrix = double([dates GHI DNI DHI others]);
matrix(isnan(matrix(:,1)),:) = []; % Not available data is discarded
data.mat = matrix;
out_name = filedata.name;
out_data = data;
end