== Function: ==
As for [https://www.meteo.unican.es/trac/meteo/wiki/EcomsUdg/Interfaces/RPackage/Python Python], a ''Matlab'' function ([https://www.meteo.unican.es/trac/MLToolbox/browser/MLToolbox/trunk/MLToolbox_experiments/antonio/system4/matlab/loadSystem4.m loadSystem4.m]) has been created in order to access the hindcast of the System4 stored in the ''SPECS-EUPORIAS Data Portal'' in a user-friendly way. This would be a typical call to the function:
{{{
[data,run,ens,frc,lat,lon] = loadSystem4(dataset,var,season,leadMonth,varargin);
}}}
Obligatory input arguments:
* `dataset`: String indicating the ''url'' of the dataset to be read (check the catalog of available datasets [https://www.meteo.unican.es/trac/meteo/wiki/EcomsUdg/DataServer/Datasets here]).
* `var`: String indicating the variable to be read.
* `season`: Cell with two strings indicating the first and final months to be read. Single months ({'Jan';'Jan'}) or seasons defined by consecutive months ({'Dec';'Feb'}) can be specified. Note that months are denoted by their three first letters.
* `leadMonth`: Forecast lead time (in months) to be considered. For instance, `leadMonth = 1` for January would refer to forecasts issued the first of December.
Optional input arguments (''varargin''):
* `members`: Vector indicating the members to consider. By default all available members are considered.
* `xlim`: Vector of length = 2 containing the minimum and maximum longitudes (in degrees) determining the domain to be considered. By default the whole domain of the dataset is considered.
* `ylim`: Vector of length = 2 containing the minimum and maximum latitudes (in degrees) determining the domain to be considered. By default the whole domain of the dataset is considered.
* `user` and `password`: Credentials for the THREDDS data server ([https://www.meteo.unican.es/trac/meteo/wiki/EcomsUdg/RPackage/Authentication authentication] is required to access the ''SPECS-EUPORIAS Data Portal'').
Outputs returned by the function:
* `data`: Cell with ''n = number of years'' 5-D matrices. Each matrix contains the forecasts for a particular year. Its first and second dimensions refer to the dataset and variable read. The third dimension correspondons to the forecasts times. Forth and fifth dimensions refer to the latitudes and longitudes of the grid boxes selected.
* `run`: Cell with ''n = number of years'' vectors. Each vector contains the initialization time (in ''datevec'' format) for a particular year.
* `ens`: Cell of ''n = number of years'' vectors. Each vector indicates the ensemble members considered.
* `frc`: Cell with ''n = number of years'' 2-D matrices. Each matrix contains the forecasts times (in ''datevec'' format) for a particular year.
* `lat`: Cell of ''n = number of years'' vectors. Each vector contains the latitudes of the domain considered.
* `lon`: Cell of ''n = number of years'' vectors. Each vector contains the longitudes of the domain considered.
== Example: ==
In this example, the '''loadSystem4''' function is used to read the maximum temperature for the Iberian Peninsula in August for the whole hindcast period (1981-2010), considering the forecasts issued the first of June (two-months lead time) for a single member (member5).
{{{
dataset = 'http://www.meteo.unican.es/tds5/dodsC/system4/System4_Seasonal_15Members.ncml';
var = 'Maximum_temperature_at_2_metres_since_last_24_hours_surface';
%% reading
[data,run,ens,frc,lat,lon] = loadSystem4(dataset,var,{'Aug';'Aug'},2,'members',5,'xlim',[-10 5],'ylim',[35 45]);
}}}
The data for the first year (August of 1981) can be plotted by using the functions from [https://www.mdm.unican.es/trac/MLToolbox MeteoLab], the open-source ''Matlab'' toolbox for statistical analysis and data mining in meteorology created by the [http://www.meteo.unican.es/en/main Santander Meteorology Group].
{{{
%% matrix of nodes
lon = lon{1};
lat = lat{1};
[nx,ny] = meshgrid(lon,lat);
nod = [nx(:)';ny(:)']';
%% data for the first year (1981)
datay1 = nan(1,size(nod,1));
for ilat = 1:length(lat)
inod = find(ismember(nod,[lon,repmat(lat(ilat),length(lon),1)],'rows') == 1);
datay1(:,inod) = nanmean(squeeze(data{1}(1,1,:,ilat,:)) - 273.15); % Kelvin to Celsius
end
%% plot
drawStationsValue(datay1,nod,'marker','t','size',0.75,'colorbar','true','clim',[20 40])
colormap(jet)
title('System4: Mean Maximum Temperature (ÂșC) in August')
}}}
[[Image(sys4_tmax_august.jpg,center)]]