Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion SDSIG-spatio-temporal/BrightSolarModel_SDSIG.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@
% +---------------------------------------------------------------------+

%% Preamble
addpath('utility\')
clear variables;
clc;
close all;
if ispc
addpath('utility\')
else
addpath('utility/')
end
InitialisePaths

%% SDSIG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,26 @@

disp('Extracting Linke turbidity');

if ~exist('supportingfiles\linke\LinkeTurbidity_Summary.mat','file')
if ~exist(['supportingfiles',filesep,'linke',filesep,'LinkeTurbidity_Summary.mat'],'file')
% Retrieve Linke Turbidity for nearest 1/12 degree grid square and month
% from the SoDa monthly data files.
% Conversion:Linke Turbidity = greyscale_value/20
tiffData = Tiff('supportingfiles/linke/January.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,1)=loadup; tiffData.close();
tiffData = Tiff('supportingfiles/linke/February.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,2)=loadup; tiffData.close();
tiffData = Tiff('supportingfiles/linke/March.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,3)=loadup; tiffData.close();
tiffData = Tiff('supportingfiles/linke/April.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,4)=loadup; tiffData.close();
tiffData = Tiff('supportingfiles/linke/May.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,5)=loadup; tiffData.close();
tiffData = Tiff('supportingfiles/linke/June.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,6)=loadup; tiffData.close();
tiffData = Tiff('supportingfiles/linke/July.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,7)=loadup; tiffData.close();
tiffData = Tiff('supportingfiles/linke/August.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,8)=loadup; tiffData.close();
tiffData = Tiff('supportingfiles/linke/September.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,9)=loadup; tiffData.close();
tiffData = Tiff('supportingfiles/linke/October.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,10)=loadup; tiffData.close();
tiffData = Tiff('supportingfiles/linke/November.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,11)=loadup; tiffData.close();
tiffData = Tiff('supportingfiles/linke/December.tif','r'); loadup = single(tiffData.read())/20; TL(:,:,12)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'January.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,1)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'February.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,2)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'March.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,3)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'April.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,4)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'May.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,5)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'June.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,6)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'July.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,7)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'August.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,8)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'September.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,9)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'October.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,10)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'November.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,11)=loadup; tiffData.close();
tiffData = Tiff(['supportingfiles',filesep,'linke',filesep,'December.tif'],'r'); loadup = single(tiffData.read())/20; TL(:,:,12)=loadup; tiffData.close();
clear tiffData loadup%clear all the tiff data.
save('supportingfiles\linke\LinkeTurbidity_Summary.mat','TL');
save(['supportingfiles',filesep,'linke',filesep,'LinkeTurbidity_Summary.mat'],'TL');
else
load('supportingfiles\linke\LinkeTurbidity_Summary.mat');
load(['supportingfiles',filesep,'linke',filesep,'LinkeTurbidity_Summary.mat']);
end
% find the latitude_central and longitude reference within the TL images
TL2_lon=linspace(-180,180,size(TL,2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@
disp('Calculating the tilted irradiance...')

% check available memory
[userview,systemview] = memory;
available_memory = userview.MemAvailableAllArrays;
available_memory = 0.;
if ispc
[userview,systemview] = memory;
available_memory = userview.MemAvailableAllArrays;
else
[r,w] = unix('free -b | grep Mem');
stats = str2double(regexp(w, '[0-9]*', 'match'));
available_memory = stats(end);
end
required_memory = 8 * length(time_1min_resolution) * number_of_houses * 2;

if available_memory*0.6666 > required_memory
Expand Down
10 changes: 5 additions & 5 deletions SDSIG-spatio-temporal/utility/CloudMotionAndClearSkyIndices.m
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@
end
end

%% write separation house_kcvalues and house_coverages
for house=1:number_of_houses
dlmwrite(['supportingfiles',filesep,'temporary_files',filesep,'separation_',num2str(house),'.txt'],separation(house,:),'-append');
dlmwrite(['supportingfiles',filesep,'temporary_files',filesep,'house_kcvalues_',num2str(house),'.txt'],house_kcvalues(house,:),'-append');
dlmwrite(['supportingfiles',filesep,'temporary_files',filesep,'house_coverages_',num2str(house),'.txt'],house_coverages(house,:),'-append');
%% write separation house_kcvalues and house_coverages
for house=1:number_of_houses
dlmwrite(['supportingfiles',filesep,'temporary_files',filesep,'separation_',num2str(house),'.txt'],separation(house,:),'-append');
dlmwrite(['supportingfiles',filesep,'temporary_files',filesep,'house_kcvalues_',num2str(house),'.txt'],house_kcvalues(house,:),'-append');
dlmwrite(['supportingfiles',filesep,'temporary_files',filesep,'house_coverages_',num2str(house),'.txt'],house_coverages(house,:),'-append');
end
end
2 changes: 1 addition & 1 deletion SDSIG-spatio-temporal/utility/InitialisePaths.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%% Script to initilise all the file paths where functions are located
home_dir=[pwd,'\'];
home_dir = [pwd, filesep];
addpath(home_dir);
addpath([home_dir,'supportingfiles']);
addpath([home_dir,'supportingfiles',filesep,'temporary_files']);
Expand Down
33 changes: 20 additions & 13 deletions SDSIG-spatio-temporal/utility/LoadUserData.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@
% order to define the settings for this simulation. The descriptions of
% what information is required in those settings is described above

fid = fopen('USER_INPUT_DATA\simulation_settings.txt');
% specify the file name according the operating system
user_data_file = ['USER_INPUT_DATA',filesep,'simulation_settings.txt'];
house_data_file = ['USER_INPUT_DATA',filesep,'house_info.csv'];
cloud_data_file = ['USER_INPUT_DATA',filesep,'cloud_base_height.csv'];
pressure_data_file = ['USER_INPUT_DATA',filesep,'pressure.csv'];
cloud_amount_data_file = ['USER_INPUT_DATA',filesep,'clound_amount.csv'];
wind_data_file = ['USER_INPUT_DATA',filesep,'wind_speed.csv'];

fid = fopen(user_data_file);
user_data = textscan(fid,'%s%s%f%f%f','delimiter',',','endofline','\r\n','headerlines',1);
fclose(fid);
start_day = cell2mat(user_data{1,1});
Expand All @@ -71,8 +79,8 @@
%% Load in the house information
% define the different properties within the simulation
% NOTE that this is an arbitrary example to set random properties of X,Y,h,azi and tilt.
house_info = csvread('house_info.csv',1,0);
number_of_houses = size(house_info,1);
house_info = csvread(house_data_file, 1, 0);
number_of_houses = size(house_info, 1);

%% Load in the raw variables data here.
% The data is required in a strict 1-hour time series format. Each variable
Expand All @@ -91,36 +99,35 @@

% cloud_base_height should be in deca-meteres (10m = 1 dm). This is the
% standard format that most ceilometers report to.
data=csvread('USER_INPUT_DATA\cloud_base_height.csv',1,0);
data = csvread(cloud_data_file, 1, 0);
% load the time stamps for the cloud base height.
time_cloud_base_height = data(:,1);
% load the cloud base height here
cloud_base_height =data(:,2);
cloud_base_height = data(:,2);
clear data

% pressure must be in mb, use space below to convert if necessary.
data=csvread('USER_INPUT_DATA\pressure.csv',1,0);
data = csvread(pressure_data_file, 1, 0);
% load the time stamps for the pressure.
time_pressure = data(:,1);
% load the pressure here
pressure =data(:,2);
pressure = data(:,2);
clear data

% cloud_amount must be in okta (where 0 to 8 out of 8 describes the
% fraction of cloud cover in eigths, and 9 okta is for obscurred/haze/mist
% or other meteorological phenomenon.
data=csvread('USER_INPUT_DATA\clound_amount.csv',1,0);
data = csvread(cloud_amount_data_file, 1, 0);
% load the time stamps for the cloud base height.
time_cloud_amount = data(:,1);
% load the cloud base height here
cloud_amount =data(:,2);
cloud_amount = data(:,2);
clear data

% wind_speed is the hourly wind_speed measured at 10m (standard) in m/s.
data=csvread('USER_INPUT_DATA\wind_speed.csv',1,0);
data = csvread(wind_data_file, 1, 0);
% load the time stamps for the wind_speed times.
time_wind_speed = data(:,1);
% load the wind speed here
wind_speed =data(:,2);
clear data

wind_speed = data(:,2);
clear data
14 changes: 11 additions & 3 deletions SDSIG-spatio-temporal/utility/SettingsForSDSIG.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,21 @@

%% Saftey checks on memory requirements
% Get the user's memory specs.
[userview,systemview] = memory;
sys_mem = 0.;
if ispc
[userview,systemview] = memory;
sys_mem = userview.MemAvailableAllArrays;
else
[r,w] = unix('free -b | grep Mem');
stats = str2double(regexp(w, '[0-9]*', 'match'));
sys_mem = stats(end);
end

if proposed_memory_requirements > userview.MemAvailableAllArrays/2
if proposed_memory_requirements > sys_mem / 2.
warning('Possible that the cloud field settings will demand too much system RAM')
end

if proposed_memory_requirements > userview.MemAvailableAllArrays/1.3
if proposed_memory_requirements > sys_mem / 1.3
error('The proposed cloud field sizings requires more PC memory than is available. Try reducing spatial_res or num_of_samples')
end

Expand Down
69 changes: 69 additions & 0 deletions SDSIG-spatio-temporal/utility/datevec2doy.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
function day = datevec2doy(mydate)
% Takes a date vector and returns the day of year, known incorrectly in the
% Geophysical community as the julian calender day, i.e. 12/31/2005
% is returned as day 365, day 06/22/2010 is returned as 173, etc... The
% function is vectorized. This function needs etime.m (R2009a and later).
%
% USAGES
% julday = datevec2doy(mydate)
%
% INPUT
% mydate: Either a 6xN or Nx6 array of date vectors, as output by
% functions like datevec.
%
% OUTPUT
% julday: An Nx1 array of julian days.
%
% -----------------------------------------------------------------------
% EXAMPLE
% %Take the current day and add normally distributed random days to the
% %date.
%
% tadd = randn(1,12);
% mydate = datevec(now)';
% mydate = repmat(mydate,1,12);
% mydate(2,:) = mydate(2,:) + tadd;
% day = datevec2doy(mydate);
% -----------------------------------------------------------------------
% Latest Edit: 24.June.2010
% Joshua D Carmichael
% josh.carmichael@gmail.com
%-----------------------------------------------------------------------

[M,N] = size(mydate);
ind = [M,N]==[6,6];

if( nnz(ind) < 1 )

error('MATLAB:datevec2doy', 'Input is not in date vector format');

end;

if(ind(1))

mydate = mydate';

end;

doy = mydate;
doy(:,2:3) = 1;
doy(:,4:6) = 0;

if(length(mydate) <= 6)

day = 1+floor(etime(mydate,doy)./(3600*24));

elseif(length(mydate) > 6)

A = mat2cell(doy,ones(size(doy,1),1),6);
B = mat2cell(mydate,ones(size(doy,1),1),6);
dt = cellfun(@etime,B,A);
day = 1+floor((dt)./(3600*24));

else

error('Matlab:etime','Not a date format');

end;

return