Coastlines/MatlabTest.m

56 lines
1.4 KiB
Matlab

%% NC DUNEX Realtime script
% Alexander Rey, August 12, 2019
clear all
cd D:\DUNEX_RT\Operation
echo off;
%% Master Model Time Step
% Every 6 hours
% Download the current UTC time from NIST
% s1 = webread('https://nist.time.gov/actualtime.cgi?lzbc=siqm9b');
% s2 = regexp(s1,'\<timestamp time\=\"(\d*)\"','tokens','once');
% n = str2double(s2);
% nistTime = datetime(n,'ConvertFrom','EpochTime','TicksPerSecond',1e6);
nistTime = datetime(datevec(now))
masterTime = dateshift(nistTime,'start','hour')-hours(6) % Assume script will run at 5 and a half hours after model start
clear nistTime
% masterTime = datetime(2019,06,15,06,00,00);
masterDate = datetime(year(masterTime),month(masterTime),day(masterTime));
%% Download new NASA Map!
host = 'gibs.earthdata.nasa.gov';
path = '/wms/epsg4326/nrt/wms.cgi?';
serverURL = ['https://' host path];
requestURL = [serverURL 'SERVICE=WMS&REQUEST=GetMap&VERSION=1.1.1&' ...
'LAYERS=VIIRS_SNPP_CorrectedReflectance_TrueColor_v1_NRT&'...
'STYLES=&FORMAT=image%2Fpng&TRANSPARENT=true&'...
'HEIGHT=800&WIDTH=1350&TIME=' datestr(masterDate-hours(12),'yyyy-mm-dd') '&SRS=EPSG:4326&'...
'BBOX=-78.5,34.0,-73.5,37.0'];
[A,R] = wmsread(requestURL);
imwrite(A,'NCcurrent.jpg')
copyfile D:\Alexander\erdas_spnad83.tif \\geoserver.engineering.queensu.ca\TIFFS\erdas_spnad83.tif