Presentation is loading. Please wait.

Presentation is loading. Please wait.

Overview %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%% validation section initialization section.

Similar presentations


Presentation on theme: "Overview %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%% validation section initialization section."— Presentation transcript:

1 Overview %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%% validation section initialization section

2 %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%

3

4 %nakedsoftware.org opensource license, copyright 2010 stephane.poirier@oifii.org % %developed by Stephane Poirier, M.Sc. Optical Physics, Remote Sensing Application Software Developer (1991-2010) % %this function is part of oifii.org's ar\sp\ Microwave- derived 30-year Canada-Alaska Daily Temperature and Snowcover Databases library % %this function is part of oifii.org's ar\sp\tsat application (lauched with ar\sp\tsat.m) %oifii.org's ar\sp\affiche_carte application is part of the oifii.org's ar\sp set of applications which %may also contain similar variant versions of this function with identical filename. % %A geophysical research paper about this work has been submitted in June 2009 for publication in JGR-Atmosphere %Royer, A. and Poirier S., Surface temperature spatial and temporal variations in North America from homogenized %satellite SMMR-SSM/I microwave measurements and reanalysis for 1979-2008, Journal of Geophysical Research - Atmosphere, %Submitted June 2009, http://www.oifii.org/tsatdb/Royer- Poirier_Microwave-derived-daily-surface- temperature_JGR2009JD012760_R2.pdf % %This study's database can be downloaded from the author web site at: %http://www.oifii.org/tsatdb/Royer-Poirier_Microwave-derived- daily-surface-temperature-db_1979-2008.zip % %this function is used to merge the (previously generated) snowcover database to the (previously generated) temperature database % %usage % 2009dec27 % tsat(1,1,1) % %version 3.4: tsat(mergetsat_flag, mergeera40_flag,mergenarr_flag), spi 2009nov24, merges the snowcover db not only to tsat % but also to era40 and narr, stephane.poirier@oifii.org % % note: the snowcover db must be generated prior to call to tsat() function. the steps for generating % the snowcover db are: 1) running function main_ratio() from ratio folder, 2) running function from % snowcover folder and finaly 3) running function tsat() from tsat folder % %version 3.0: tsat(), spi 2009nov23, k:\ drive modif, stephane.pe.poirier@gmail.com %version 0.2 tsat(), avril 2009 april, yearmax revision %version 0.1 tsat(), merges the snowcover db (mask) with the satellite (smmr/ssmi derived) temperature db % %nakedsoftware.org opensource license, copyright 2010 stephane.poirier@oifii.org

5 %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%

6 function tsat(mergetsat_flag,mergeera40_flag,mergenarr_flag)

7 validation section

8 if(nargin<3) mergenarr_flag=0;end if(nargin<2) mergeera40_flag=0;end if(nargin<1) mergetsat_flag=0;end display(['executing tsat(',num2str(mergetsat_flag),',',num2str(mergeera40_flag),',',num2str(mergenarr_flag),')']);

9 initialization section

10

11 [driveletter]=getsourceimagedatabasedrive();if(~exist(drivele tter,'dir'))display([driveletter,' drive not ready']);return;end load('srcarsplib_path.mat'); load('srcimgdb_paths.mat'); %outputpath='G:\tsat\canada\'; %outputpath_tsat='k:\g-tsat\canada\'; %outputpath_tsat='K:\c-db-bd_surface-temperature_1979- 2008\canada\'; outputpath_tsat=srcimgdb_path_db_surface_temperature; %outputpath='G:\tsat\canada\'; %inputpath_era40='K:\d-era40_moy\ease\160x240\Canada\'; inputpath_era40=srcimgdb_path_era40_moy; % %outputpath_era40='K:\d-era40_scdb\'; %outputpath_era40='K:\d-era40_scdb\ease\160x240\Canada\'; outputpath_era40=srcimgdb_path_era40_scdb; %outputpath='G:\tsat\canada\'; %inputpath_narr='k:\g-narr_moy\ease\160x240\Canada\'; inputpath_narr=srcimgdb_path_narr_moy; %outputpath_era40='K:\d-era40_scdb\'; %outputpath_narr='k:\g-narr_scdb\ease\160x240\Canada\'; outputpath_narr=srcimgdb_path_narr_scdb; yearmax=2008; %%%%%% %merge tsat %%%%%% if(mergetsat_flag==1) %for year=yearmax:yearmax for year=1979:yearmax %outputpathname_tsat=[outputpath_tsat,num2str(year)]; outputpathname_tsat=fullfile(outputpath_tsat,num2str(year)); if(exist(outputpathname_tsat,'dir')==0) mkdir(outputpathname_tsat); else display(['outputpath_tsat ',outputpathname_tsat,' already exists']); display('choose another output directory or erase existing one'); display('returning without generating tsat database'); pause(); return; end matrice1=zeros(160,240); matrice2=zeros(160,240); matrice3=zeros(160,240); %for year=1979:2007 for year=1979:yearmax display(['tsat - merging year ',num2str(year)]); for day=1:366 %display(['day ',num2str(day)]); if((day==366)&&(((~rem(year,4)&rem(year,100))|~rem(year,400)) ==0)); continue; end %A) snowcover mask DB, inputdir if(year<=1987) %A1) smmr %filename1=['D:\smmr_snowcover\canada\',num2str(year),'\',spr intf('%03d',day)]; %filename1=['k:\d- smmr_snowcover\canada\',num2str(year),'\',sprintf('%03d',day) ]; filename1=fullfile(srcimgdb_path_smmr_snowcover,num2str(year),sprintf('%03d',day)); else %A2) ssmi %filename1=['D:\ssmi_snowcover\canada\',num2str(year),'\',spr intf('%03d',day)]; %filename1=['k:\d- ssmi_snowcover\canada\',num2str(year),'\',sprintf('%03d',day) ]; filename1=fullfile(srcimgdb_path_ssmi_snowcover,num2str(year),sprintf('%03d',day)); end [pathstr,name,ext,versn]=fileparts(filename1); [d1 d2 f]=autodimformat(pathstr,name); dim=[d1 d2]; format=f; fid=fopen(filename1, 'r'); if(fid~=-1) matrice1=fread(fid,[1 inf],format); matrice1=reshape(matrice1,160,240); fclose(fid); else matrice1=zeros(160,240); end indicessnow=find(matrice1==1); %B) Ts DB if(year<=1982) %filename2=['k:\d-smmr_ts- moy\160x240\Canada\',num2str(year),'\37GHz\TS_D',sprintf('%03 d',day)]; filename2=fullfile(srcimgdb_path_smmr_ts_moy,num2str(year),'3 7GHz',['TS_D',sprintf('%03d',day)]); elseif((year<=1986)||((year==1987)&&(day<192))) %B1) smmr D:\smmr_ts-corr\smmr_ts- moy\160x240\Canada\1979\37GHz %filename2=['D:\smmr_ts-corr\smmr_ts- moy\160x240\Canada\',num2str(year),'\37GHz\TS_D',sprintf('%03 d',day)]; %filename2=['k:\d-smmr_ts-corr\smmr_ts- moy\160x240\Canada\',num2str(year),'\37GHz\TS_D',sprintf('%03 d',day)]; filename2=fullfile(srcimgdb_path_smmr_ts_corr,num2str(year),' 37GHz',['TS_D',sprintf('%03d',day)]); elseif(((year>1987)&&(year =192)) ) %B2) ssmi D:\ssmi_ts-corr\ssmi_ts- moy\160x240\Canada\1987\37GHz %filename2=['D:\ssmi_ts-corr\ssmi_ts- moy\160x240\Canada\',num2str(year),'\37GHz\TS_D',sprintf('%03 d',day)]; %filename2=['k:\d-ssmi_ts-corr\ssmi_ts- moy\160x240\Canada\',num2str(year),'\37GHz\TS_D',sprintf('%03 d',day)]; filename2=fullfile(srcimgdb_path_ssmi_ts_corr,num2str(year),' 37GHz',['TS_D',sprintf('%03d',day)]); elseif((year>=1992)&&(year<2002)) %B3) ssmi D:\ssmi_ts- moy\160x240\Canada\1992\37GHz %filename2=['D:\ssmi_ts- moy\160x240\Canada\',num2str(year),'\37GHz\TS_D',sprintf('%03 d',day)]; %filename2=['k:\d-ssmi_ts- moy\160x240\Canada\',num2str(year),'\37GHz\TS_D',sprintf('%03 d',day)]; filename2=fullfile(srcimgdb_path_ssmi_ts_moy,num2str(year),'3 7GHz',['TS_D',sprintf('%03d',day)]); %elseif((year>=2002)&&(year<2008)) elseif((year>=2002)&&(year<=yearmax)) %B4) ssmi D:\ssmi_ts-moy- narr\160x240\Canada\2002\37GHz %filename2=['D:\ssmi_ts-moy- narr\160x240\Canada\',num2str(year),'\37GHz\TS_D',sprintf('%0 3d',day)]; %filename2=['k:\d-ssmi_ts-moy- narr\160x240\Canada\',num2str(year),'\37GHz\TS_D',sprintf('%0 3d',day)]; filename2=fullfile(srcimgdb_path_ssmi_ts_moy_narr,num2str(yea r),'37GHz',['TS_D',sprintf('%03d',day)]); end [pathstr,name,ext,versn]=fileparts(filename2); [d1 d2 f]=autodimformat(pathstr,name); dim=[d1 d2]; format=f; fid=fopen(filename2,'r'); if(fid~=-1) matrice2=fread(fid,[1 inf],format); matrice2=reshape(matrice2,160,240); fclose(fid); else matrice2=zeros(160,240); end %C) Tsat DB = snowcover mask DB + Ts DB %filename3=['D:\tsat\canada\',num2str(year),'\',sprintf('%03d ',day)]; filename3=fullfile(outputpath_tsat,num2str(year),sprintf('%03 d',day)); fid=fopen(filename3,'w'); if(fid~=-1) matrice3=matrice2; %temp in kelvin matrice3(indicessnow)=0; %NaN fwrite(fid,matrice3,'float'); %32bit fclose(fid); end end%for day end%for year end%if(mergetsat_flag==1) %%%%%% %merge era40 %%%%%% if(mergeera40_flag==1) %for year=yearmax:yearmax %for year=1979:yearmax for year=1979:2002 %outputpathname_era40=[outputpath_era40,num2str(year)]; outputpathname_era40=fullfile(outputpath_era40,num2str(year)) ; if(exist(outputpathname_era40,'dir')==0) mkdir(outputpathname_era40); else display(['outputpath_era40 ',outputpathname_era40,' already exists']); display('choose another output directory or erase existing one'); display('returning without generating era40_scdb database'); pause(); return; end matrice1=zeros(160,240); matrice2=zeros(160,240); matrice3=zeros(160,240); %for year=1979:yearmax for year=1979:2002 display(['era40 - merging year ',num2str(year)]); day_start=1; day_end=366;if(year==2002)day_end=243;end for day=1:day_end %display(['day ',num2str(day)]); if((day==366)&&(((~rem(year,4)&rem(year,100))|~rem(year,400)) ==0)); continue; end %A) snowcover mask DB, inputdir if(year<=1987) %A1) smmr %filename1=['D:\smmr_snowcover\canada\',num2str(year),'\',spr intf('%03d',day)]; %filename1=['k:\d- smmr_snowcover\canada\',num2str(year),'\',sprintf('%03d',day) ]; filename1=fullfile(srcimgdb_path_smmr_snowcover,num2str(year),sprintf('%03d',day)); else %A2) ssmi %filename1=['D:\ssmi_snowcover\canada\',num2str(year),'\',spr intf('%03d',day)]; %filename1=['k:\d- ssmi_snowcover\canada\',num2str(year),'\',sprintf('%03d',day) ]; filename1=fullfile(srcimgdb_path_ssmi_snowcover,num2str(year),sprintf('%03d',day)); end [pathstr,name,ext,versn]=fileparts(filename1); [d1 d2 f]=autodimformat(pathstr,name); dim=[d1 d2]; format=f; fid=fopen(filename1, 'r'); if(fid~=-1) matrice1=fread(fid,[1 inf],format); matrice1=reshape(matrice1,160,240); fclose(fid); else matrice1=zeros(160,240); end indicessnow=find(matrice1==1); %B) raw era40 DB filename2=fullfile(inputpath_era40,num2str(year),sprintf('eas e%03d',day)); [pathstr,name,ext,versn]=fileparts(filename2); [d1 d2 f]=autodimformat(pathstr,name); dim=[d1 d2]; format=f; fid=fopen(filename2,'r'); if(fid~=-1) matrice2=fread(fid,[1 inf],format); matrice2=reshape(matrice2,160,240); fclose(fid); else matrice2=zeros(160,240); end %C) era40 with snowmask DB = snowcover mask DB + raw era40 DB %filename3=['D:\tsat\canada\',num2str(year),'\',sprintf('%03d ',day)]; filename3=fullfile(outputpath_era40,num2str(year),sprintf('ea se%03d',day)); fid=fopen(filename3,'w'); if(fid~=-1) matrice3=matrice2; %temp in kelvin matrice3(indicessnow)=0; %NaN fwrite(fid,matrice3,'float'); %32bit fclose(fid); end end%for day end%for year end%if(mergeera40_flag==1) %%%%%% %merge narr %%%%%% if(mergenarr_flag==1) %for year=yearmax:yearmax %for year=1979:yearmax for year=1979:yearmax %outputpathname_narr=[outputpath_narr,num2str(year)]; outputpathname_narr=fullfile(outputpath_narr,num2str(year)); if(exist(outputpathname_narr,'dir')==0) mkdir(outputpathname_narr); else display(['outputpath_narr ',outputpathname_narr,' already exists']); display('choose another output directory or erase existing one'); display('returning without generating narr_scdb database'); pause(); return; end matrice1=zeros(160,240); matrice2=zeros(160,240); matrice3=zeros(160,240); %for year=1979:yearmax for year=1979:yearmax display(['narr - merging year ',num2str(year)]); day_start=1; day_end=366; for day=1:day_end %display(['day ',num2str(day)]); if((day==366)&&(((~rem(year,4)&rem(year,100))|~rem(year,400)) ==0)); continue; end %A) snowcover mask DB, inputdir if(year<=1987) %A1) smmr %filename1=['D:\smmr_snowcover\canada\',num2str(year),'\',spr intf('%03d',day)]; %filename1=['k:\d- smmr_snowcover\canada\',num2str(year),'\',sprintf('%03d',day) ]; filename1=fullfile(srcimgdb_path_smmr_snowcover,num2str(year),sprintf('%03d',day)); else %A2) ssmi %filename1=['D:\ssmi_snowcover\canada\',num2str(year),'\',spr intf('%03d',day)]; %filename1=['k:\d- ssmi_snowcover\canada\',num2str(year),'\',sprintf('%03d',day) ]; filename1=fullfile(srcimgdb_path_ssmi_snowcover,num2str(year),sprintf('%03d',day)); end [pathstr,name,ext,versn]=fileparts(filename1); [d1 d2 f]=autodimformat(pathstr,name); dim=[d1 d2]; format=f; fid=fopen(filename1, 'r'); if(fid~=-1) matrice1=fread(fid,[1 inf],format); matrice1=reshape(matrice1,160,240); fclose(fid); else matrice1=zeros(160,240); end indicessnow=find(matrice1==1); %B) raw narr DB filename2=fullfile(inputpath_narr,num2str(year),sprintf('ease %03d',day)); [pathstr,name,ext,versn]=fileparts(filename2); [d1 d2 f]=autodimformat(pathstr,name); dim=[d1 d2]; format=f; fid=fopen(filename2,'r'); if(fid~=-1) matrice2=fread(fid,[1 inf],format); matrice2=reshape(matrice2,160,240); fclose(fid); else matrice2=zeros(160,240); end %C) era40 with snowmask DB = snowcover mask DB + raw era40 DB %filename3=['D:\tsat\canada\',num2str(year),'\',sprintf('%03d ',day)]; filename3=fullfile(outputpath_narr,num2str(year),sprintf('eas e%03d',day)); fid=fopen(filename3,'w'); if(fid~=-1) matrice3=matrice2; %temp in kelvin matrice3(indicessnow)=0; %NaN fwrite(fid,matrice3,'float'); %32bit fclose(fid); end end%for day end%for year end%if(mergenarr_flag==1) end%function


Download ppt "Overview %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%% validation section initialization section."

Similar presentations


Ads by Google