Overview %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%nakedsoftware. org opensource license, copyright 2010 stephane %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\'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 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 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%version 3.0: ssmi_f8f11f13_correctiona(reanalysismodel), spi 2009sept19, stephane.pe.poirier@gmail.com % used (along with *correctionb.m and *correctionc.m) for computing the bias between f8 and f11f13 satellite periods % % *correctiona.m computes either era40-derived tsmoy-smmr.mat and tsmoy-ssmi.mat (written to D:\smmr_ts-corr\matrices-de-correction\1988-2008 folders) % or narr-derived tsmoy-smmr.mat and tsmoy-ssmi.mat (written to D:\smmr_ts-corr\matrices-de-correction_narr\1988-2002 folders) % depending upon the specified reanalysismodel input parameter (defaults to narr-derived) %developer note: future generalized version should replace: m0,m6,m12 and m19 (or m0,m3,m6,m9,m12,m15,m18,m21) by ms=cell(4,1) (or ms=cell(8,1)) % ******************************************************** % ***** Programme ayant pour but de créer une matrice **** % ***** de correction pour raccorder F8 avec F11/F13 **** % ssmi_f8f11f13_correctiona.m % ssmi_f8f11f13_correctionb.m % ssmi_f8f11f13_correctionc.m % F08 SSM/I Jul 1987 to Dec 1991 % F10 SSM/I Dec 1990 to Nov 1997 % F11 SSM/I Dec 1991 to May 2000 % F13 SSM/I May 1995 to present % F14 SSM/I May 1997 to present % F15 SSM/I Dec 1999 to Aug 2006 % Nous n'utilisons que F8, F11 and F13 % Etape a) pour chaque année (1988 a 2002), correctiona.m % genere les matrices de tempéatures estivales moyennes % tsmoy.mat et teramoy.mat %clear all; %close all; %clc function ssmi_f8f11f13_correctiona(reanalysismodel) if nargin<1 reanalysismodel='narr-derived';end driveletter=getsourceimagedatabasedrive(); %spi 2009sept19, driveletter='k:\'; if strcmp(reanalysismodel,'era40-derived') outputpathname=[driveletter,'d-ssmi_ts-corr\matrices-de-correction\']; intputpathname_ssmi_tsnorm=[driveletter,'d-ssmi_ts-norm\160x240\Canada\']; intputpathname_reanalysismodel=[driveletter,'d-era40\ease\160x240\Canada\']; dailyfreq=4; %era40 is 4 times daily (temporal resolution 6hrs) elseif strcmp(reanalysismodel,'narr-derived') outputpathname=[driveletter,'d-ssmi_ts-corr\matrices-de-correction-narr\']; intputpathname_ssmi_tsnorm=[driveletter,'d-ssmi_ts-norm-narr\160x240\Canada\']; %intputpathname_reanalysismodel=[driveletter,'d-era40\ease\160x240\Canada\']; %SP: to be discussed with AR intputpathname_reanalysismodel=[driveletter,'g-narr\ease\160x240\Canada\']; %SP: AR demanded single model dependency dailyfreq=8; %narr is 8 times daily (temporal resolution 3hrs) else display('error in ssmi_f8f11f13_correctiona(), wrong input paramater'); return; end %xlim=[181 340]; %spi, warning, xlim is a matlab function %ylim=[231 470]; %spi, warning, ylim is a matlab function %h=waitbar(0,'Traitement de l''annee 1988 en cours ...'); for an=1988:2002 ms=cell(dailyfreq,1); %ms is replacing former m0,m6,m12 and m19 (or m0,m3,m6,m9,m12,m15,m18,m21) era40-dailyfreq-adapted (or narr-daily-adapted) matrices TSs=cell(dailyfreq,1); %TSs is replacing Ts0,Ts6,Ts12,Ts18 (or Ts0,Ts3,Ts6,Ts9,Ts12,Ts15,Ts18,Ts21) Tsmoys=cell(dailyfreq,1); %Tsmoys{dailyfreq_index} is replacing Tsmoy0,Tsmoy6,Tsmoy12,Tsmoy18 (or Tsmoy0,Tsmoy3,Tsmoy6,Tsmoy9,Tsmoy12,Tsmoy15,Tsmoy18,Tsmoy21) %waitbar((an-1988)/16,h,['Traitement de l''annee ',num2str(an),' en cours ...']) tic; disp(['Traitement de l''annee ',num2str(an),' en cours ...']); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %1.1) load smmr_ts-corr - charger ssmi ts corrige pour la periode de recouvrement doy_summer_start=182; doy_summer_end=243; %for i=182:243 %243-182+1=62jours for i=doy_summer_start:doy_summer_end %243-182+1=62jours %lecture des ts normalises aux 6 heures (pour chacun des jours d'ete/juillet et aout) %fid=fopen(['G:\TS\TS_6h\canada\',num2str(an),'\TS37_',sprintf('%03d',i)],'r'); %fid=fopen(['D:\ssmi_ts-norm\160x240\Canada\',num2str(an),'\37GHz\',sprintf('TS_D%03d',i)],'r'); fid=fopen([intputpathname_ssmi_tsnorm,num2str(an),'\37GHz\',sprintf('TS_D%03d',i)],'r'); if fid==-1 %m=zeros(160,240,4)*NaN; %spi, *NaN avec zeros() semble inutile, considerer remplacer zeros() par ones() m=zeros(160,240,dailyfreq)*NaN; %spi, *NaN avec zeros() semble inutile, considerer remplacer zeros() par ones() M=fread(fid,[1 inf],'float32'); %m=reshape(M,160,240,4); m=reshape(M,160,240,dailyfreq); st=fclose(fid); %SP generalized version %concatenation de chaque jour en 4 matrices (0h,6h,12h et 18h) a 3 dimensions (x,y,jour) %concatenation into 4 matrices (ms{1} for m0, ms{2} for m6, ms{3) for m12 and ms{4} for m18) for dailyfreq_index=1:dailyfreq ms{dailyfreq_index}(:,:,i-(doy_summer_start-1))=m(:,:,1);ms{dailyfreq_index}(ms{dailyfreq_index}==0)=NaN; clear m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %1.2) pour chacun des pixels, calcul la moyenne estivale ts normalises for i=1:160 %waitbar((an-1988+(i/160/2))/16,h,['Traitement de l''annee ',num2str(an),' en cours ...']) for j=1:240 %pour chacun des pixels, calcul la moyenne estivale ts normalises %for k=1:62 for k=1:(doy_summer_end-doy_summer_start+1) %ms{dailyfreq_index} replacing m0,m6,m12,m18 (or m0,m3,m6,m9,m12,m15,m18,m21) %TSs{dailyfreq_index} replacing Ts0,Ts6,Ts12,Ts18 (or Ts0,Ts3,Ts6,Ts9,Ts12,Ts15,Ts18,Ts21) if ms{dailyfreq_index}(i,j,k)==0 | ms{dailyfreq_index}(i,j,k)==-10 TSs{dailyfreq_index}(k)=NaN; TSs{dailyfreq_index}(k)=ms{dailyfreq_index}(i,j,k); %Tsmoys{dailyfreq_index} replacing Tsmoy0,Tsmoy6,Tsmoy12,Tsmoy18 (or Tsmoy0,Tsmoy3,Tsmoy6,Tsmoy9,Tsmoy12,Tsmoy15,Tsmoy18,Tsmoy21) Tsmoys{dailyfreq_index}(i,j)=moyenne(TSs{dailyfreq_index}); %moyenne estivale ts normalises a l'heure(dailyfreq_index) pour chacun des pixels Tsmoy=zeros(160,240); Tsmoy=Tsmoy+Tsmoys{dailyfreq_index}; Tsmoy=Tsmoy/dailyfreq; %ts moyenne estivale pour chacun des pixels %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %1.3) saves output tsmoy-smmr.mat to file pathname=fullfile(outputpathname,num2str(an)); if(~isdir(pathname)) mkdir(pathname); end save(fullfile(pathname,'tsmoy.mat'),'Tsmoy'); %save Tsmoy.mat Tsmoy clear M m ms Ts TSs Tsmoy Tsmoys fid i j k st %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2.1) load reanalysis model (era40 or narr) - for the whole covered period TMs=cell(dailyfreq,1); %TMs is replacing Tera0,Tera6,Tera12,Tera18 (or Tnarr0,Tnarr3,Tnarr6,Tnarr9,Tnarr12,Tnarr15,Tnarr18,Tnarr21) TMmoys=cell(dailyfreq,1); %TMmoys{dailyfreq_index} is replacing Teramoy0,Teramoy6,Teramoy12,Teramoy18 (or Tnarrmoy0,Tnarrmoy3,Tnarrmoy6,Tnarrmoy9,Tnarrmoy12,Tnarrmoy15,Tnarrmoy18,Tnarrmoy21) %fid=fopen(['G:\ERA40_',num2str(an),'\era_in_ease\',num2str(an),'\',sprintf('%03d',i)],'r'); %fid=fopen(['D:\era40\ease\160x240\Canada\',num2str(an),'\',sprintf('ease%03d',i)],'r'); fid=fopen([intputpathname_reanalysismodel,num2str(an),'\',sprintf('ease%03d',i)],'r'); %mm=zeros(160,240,4)*NaN; %spi, etait: mm=zeros(721,721,4)*NaN; mm=zeros(160,240,dailyfreq)*NaN; %spi, etait: mm=zeros(721,721,4)*NaN; MM=fread(fid,[1 inf],'float32'); %mm=reshape(MM,160,240,4); %spi, etait: mm=reshape(MM,721,721,4); mm=reshape(MM,160,240,dailyfreq); %spi, etait: mm=reshape(MM,721,721,4); %ms{dailyfreq_index} ms{dailyfreq_index}(:,:,i-(doy_summer_start-1))=mm(:,:,1);ms{dailyfreq_index}(ms{dailyfreq_index}==0)=NaN; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2.2) pour chacun des pixels, calcul la moyenne estivale reanalysis model (era40 or narr) %waitbar((an-1988+(i/160/2+.5))/16,h,['Traitement de l''annee ',num2str(an),' en cours ...']) %pour chacun des pixels, calcul la moyenne estivale temperature era40 if ms{dailyfreq_index}(i,j,k)==0 TMs{dailyfreq_index}(k)=NaN; TMs{dailyfreq_index}(k)=ms{dailyfreq_index}(i,j,k); TMmoys{dailyfreq_index}(i,j)=moyenne(TMs{dailyfreq_index}); %moyenne estivale temperature model a l'heure(dailyfreq_index) pour chaque pixels if(dailyfreq==4) Teramoy=zeros(160,240); Teramoy=Teramoy+TMmoys{dailyfreq_index}; Teramoy=Teramoy/dailyfreq; %ts moyenne estivale pour chacun des pixels elseif(dailyfreq==8) Tnarrmoy=zeros(160,240); Tnarrmoy=Tnarrmoy+TMmoys{dailyfreq_index}; Tnarrmoy=Tnarrmoy/dailyfreq; %ts moyenne estivale pour chacun des pixels %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2.3) saves output Teramoy or Tnarrmoy to *.mat file %cd(['F:\Work\correction\',num2str(an)]); %pathname=fullfile('D:\ssmi_ts-corr\matrices-de-correction\',num2str(an)); save(fullfile(pathname,'teramoy.mat'),'Teramoy'); %save teramoy.mat Teramoy save(fullfile(pathname,'tnarrmoy.mat'),'Tnarrmoy'); %save tnarrmoy.mat Tnarrmoy %cd F:\Work; %clear MM mm m0 m6 m12 m18 Tera0 Tera6 Tera12 Tera18 Tnarr0 Tnarr3 Tnarr6 Tnarr9 Tnarr12 Tnarr15 Tnarr18 Tnarr21 Teramoy0 Teramoy6 Teramoy12 Teramoy18 Tnarrmoy0 Tnarrmoy3 Tnarrmoy6 Tnarrmoy9 Tnarrmoy12 Tnarrmoy15 Tnarrmoy18 Tnarrmoy21 fid i j k st clear MM mm ms TMs TMmoys fid i j k st toc; %close(h) whos end%function