Presentation is loading. Please wait.

Presentation is loading. Please wait.

Overview %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%

Similar presentations


Presentation on theme: "Overview %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%"— Presentation transcript:

1 Overview %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%

2

3

4 %nakedsoftware.org opensource license, copyright 2010 % %developed by Stephane Poirier, M.Sc. Optical Physics, Remote Sensing Application Software Developer ( ) % %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\'this folder' application (lauched with ar\sp\'this file'.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 , Journal of Geophysical Research - Atmosphere, %Submitted June 2009, 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_ zip % %this function is used to display the raw microwave raster data (NSIDC's SMMR and SSMI satellite, ref. nsidc.org) % %usage: % 20yymmmdd % %version 0.0, 20yymmmdd, spi, initial function draft % %nakedsoftware.org opensource license, copyright 2010

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

6

7 %version 0.5: 2009sept21, spi, stephane poirier, modif. d:\ for k:\d-, c:\ for k:\c- and g:\ for k:\g- %version 0.4: lireTSmoyen_lissage(path_tsmoy,jd_start,jd_end,display,smooth ing3x3,x_pixel,y_pixel) support du parametre smoothing3x3 quand x_pixel et y_pixel sont specifies %version 0.3: lireTSmoyen_lissage(path_tsmoy,jd_start,jd_end,display,smooth ing3x3,x_pixel,y_pixel) ajout des vecteurs de coordonnees display x_pixel y_pixel %version 0.2, lireTSmoyen_lissage.m modification pour integrer un lissage 3x3 si desiré %version 0.1, adaptation de lireTSmoy.m du dossier C:\mw\am- mt\work-programmes %version 0.1, adaptation de lireTSmoy(zone,an,phase,jour1,jour2) applicable %version 0.1, au ts-moy journaliers prealablement calcules. cette fonction %version 0.1, lis les ts-moy journaliers d'une series de jours juliens et %version 0.1, retourne la moyenne temporelle % %parametre path_tsmoy peut etre un des suivants: % %D:\smmr_ts-corr\smmr_ts-moy\160x240\Canada\1987\37GHz %D:\smmr_ts-moy\160x240\Canada\1979\37GHz %D:\ssmi_ts-corr\ssmi_ts-moy\160x240\Canada\1987\37GHz %D:\ssmi_ts-moy\160x240\Canada\1987\37GHz %D:\ssmi_ts-moy-narr\160x240\Canada\2002\37GHz function TS=lireTSmoyen_lissage(path_tsmoy,jd_start,jd_end,display,smo othing3x3,x_pixel,y_pixel); if nargin<7 y_pixel=[]; end %y display coordinate vector, defaults to empty if nargin<6 x_pixel=[]; end %x display coordinate vector, defaults to empty if nargin<5 smoothing3x3=0; end %0=off, 1=on if nargin<4 display=0; end TS=[]; if nargin<3 disp('lireTSmoyen(''k:\d-smmr_ts-corr\smmr_ts- moy\160x240\Canada\1987\37GHz'',jd_start,jd_end,0,0)'); disp('lireTSmoyen(''k:\d-smmr_ts-corr\smmr_ts- moy\160x240\Canada\1987\37GHz'',jd_start,jd_end,0,0,[ ],[ ])'); return; end if exist(path_tsmoy,'file')==0 disp(['lireTSmoyen_lissage(): path_tsmoy variable is invalid, ',path_tsmoy]); return; end if(~isempty(strfind(path_tsmoy,'160x240'))&&isempty(strfind(p ath_tsmoy,'281x281'))&&isempty(strfind(path_tsmoy,'721x721')) &&isempty(strfind(path_tsmoy,'tibet'))&&isempty(strfind(path_ tsmoy,'russie'))) dim=[ ]; %eventually use [dim1,dim2,format]=autodimformat(chemin,nomfichier); region='canada'; format='float32'; else disp(['lireTSmoyen_lissage: ','281x281',', ','721x721',', ','tibet','and ','russie','image data not supported']); return; end if(isempty(x_pixel)&&isempty(y_pixel)) %load the whole image file m=mask(2,2); for i_jd=jd_start:jd_end filename=['TS_D',sprintf('%03d',i_jd)]; pathfilename=fullfile(path_tsmoy,filename); if exist(pathfilename,'file')~=0 fid=fopen(pathfilename,'r'); matrice=fread(fid,dim,'float32'); fclose(fid); clear fid; %assuming data in kelvin %assuming mask saved as zeros %assuming uncomputed values saved as zeros matrice(matrice==-100)=NaN; matrice(matrice==-20)=NaN; matrice(matrice==-10)=NaN; matrice(matrice==0)=NaN; TS=cat(3,TS,matrice); else disp(['lireTSmoyen: file ',pathfilename,' notfound']); end TS=permute(TS,[3 1 2]); TS=nanmoy(TS); TS=permute(TS,[2 3 1]); TS(m==0)=NaN; %added spi if(smoothing3x3) a=[1/9 1/9 1/9;1/9 1/9 1/9;1/9 1/9 1/9]; %averaging 3x3 kernel TS=reshape(TS,160,240); TS=conv2(TS,a,'same'); end %TS(isnan(TS))=0; %leave NaN to NaN if any TS(m==0)=0; if display==1 figure;imagesc(rot90(TS'));axis;colorbar; end elseif(~isempty(x_pixel)&&~isempty(y_pixel)) %load only pixels of interest using x_pixel and y_pixel vectors in display coordinates if(max(size(x_pixel))~=max(size(y_pixel))) disp('x_pixel vector and y_pixel vector must be the same size'); return; end for i_jd=jd_start:jd_end TS_stations=[]; for ij=1:max(size(x_pixel)) if smoothing3x3==0 filename=['TS_D',sprintf('%03d',i_jd)]; pathfilename=fullfile(path_tsmoy,filename); if exist(pathfilename,'file')~=0 fid=fopen(pathfilename,'r'); [x_pix,y_pix]=pixel2pix(x_pixel(ij),y_pixel(ij),region); fpo_inbytes=pix2fpo(x_pix,y_pix,dim(1,1),dim(1,2),format,regi on); status = fseek(fid,fpo_inbytes,'bof'); %3) lecture du pixel temp=fread(fid,1,'float32'); fclose(fid); if(temp==-100)temp=NaN; end if(temp==-20)temp=NaN; end if(temp==-10)temp=NaN; end if(temp==0)temp=NaN; end TS_stations=cat(2,TS_stations,temp); end elseif smoothing3x3==1 ktemp=0; kcount=0; kx_pixel=[ ]; ky_pixel=[ ]; for k=1:9 temp=NaN; %todo, loop 9 times checking boundaries on pixel(ij)+k_pixel(k) if( ((x_pixel(ij)+kx_pixel(k))>0) && ((x_pixel(ij)+kx_pixel(k))<(dim(1,2)+1)) &&... ((y_pixel(ij)+ky_pixel(k))>0) && ((y_pixel(ij)+ky_pixel(k))<(dim(1,1)+1)) ) filename=['TS_D',sprintf('%03d',i_jd)]; pathfilename=fullfile(path_tsmoy,filename); if exist(pathfilename,'file')~=0 fid=fopen(pathfilename,'r'); [x_pix,y_pix]=pixel2pix(x_pixel(ij)+kx_pixel,y_pixel(ij)+ky_p ixel,region); fpo_inbytes=pix2fpo(x_pix,y_pix,dim(1,1),dim(1,2),format,regi on); status = fseek(fid,fpo_inbytes,'bof'); %3) lecture du pixel temp=fread(fid,1,'float32'); fclose(fid); if(temp==-100)temp=NaN; end if(temp==-20)temp=NaN; end if(temp==-10)temp=NaN; end if(temp==0)temp=NaN; end end if~isnan(temp) ktemp=ktemp+temp; kcount=kcount+1; end end %if end %for k=1:9 temp=NaN; if(kcount>0) temp=ktemp/kcount; end TS_stations=cat(2,TS_stations,temp); end %smoothing3x3==0/1 end TS=cat(1,TS,TS_stations); end else disp('case not supported'); end %if(isempty(x_pixel)&&isempty(y_pixel)) end %function


Download ppt "Overview %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%"

Similar presentations


Ads by Google