Overview %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%
%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\ratio application (lauched with ar\sp\main_ratio.m) %oifii.org's ar\sp\ratio 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: % daily-surface-temperature-db_ zip % %this function is used to compute first day of snow (jour1neige) % %version 0.2 calcul_jour1neige(zone,dataset,an,phase,pol,pathratio), 2009dec13, spi, revision %version 0.1 calcul_jour1neige(zone,dataset,an,phase,pol,pathratio) % % fonction qui calcule le 1er jour de neige % % FCT ASSOCIEES % - [ratio] =lire_ratio(zone,dataset,an,phase,x,y,j1,j2,type); % type = 'filtre' % - [seuil] = lire_seuil(zone,phase,pol,an); % % note spi: voir these arnaud mialon, page 48 et page 49 % rev. spi: juillet 2007, previous year dependency fix % rev. spi: juillet 2007, rep dependance annee precedente % calcul seuil, cas multiples, voir fonction calcul_moyecart() % % note spi: voir these arnaud mialon, page 48 et page 49 % IDEE : % __________|______ % / | \ % RATIO AN - 1 / | \ % ----/ |------\ seuil AN- 1 % / | \ % ____________/ | \ % | % AN-1 AN % %nakedsoftware.org opensource license, copyright 2010
%%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%
function [jour1]=calcul_jour1neige(zone,dataset,an,phase,pol,pathratio ) prevdir=pwd; if strcmp(zone,'canada')==1 dim=[ ]; biss=IsLeapYear(an); m=masque(2,2); elseif strcmp(zone,'russie')==1 dim=[ ]; biss=IsLeapYear(an); m=masque(7,2); elseif strcmp(zone,'tibet')==1 dim=[90 180]; biss=IsLeapYear(an); end %{ %since nbrejour=220; further down below if biss==1 nbrejour=366; else nbrejour=365; end %} [indmask]=find(m==1); [indmask1 indmask2]=find(m==1); %% initialisation de la matrice jour1 jour1=-10.*ones(dim(1)*dim(2),1); if(((dataset==1)&&(an==1978))||((dataset==2)&&(an==1987))) display(['calcul_jour1neige() ne peut etre evalue pour les annees partielles tel que l''annee ',num2str(an),' (dataset=',num2str(dataset),')']); warning; return; else %% chargement des matrices de l'année : an % rien ne sert de prendre toute l'année, juste les 200 1er jours ratio=[]; n=0; nbrejour=220; for i=1:60:nbrejour n=n+1; i2=60+60*(n-1); if i2>nbrejour i2=nbrejour; end [r]=lire_ratio(zone,dataset,an,phase,'all','all',i,i2,'filtre ',pathratio); ratio=cat(3,ratio,r); clear r; end % on ne garde que les pixels définis par le mask ratio=reshape(ratio,dim(1)*dim(2),nbrejour); ratio=ratio(indmask,:); [d1 d2]=size(ratio); end %% chargement de la matrice seuil de l'année : an-1 [s]=lire_seuil(zone,phase,pol,an-1,pathratio); %s is the summer ratio level (summer delta tb level) s=reshape(s,dim(1)*dim(2),1); s=s(indmask,:); seriej1=[]; %for each ground pixel for i=1:d1 %d1 is the number of ground pixels (obtained from length(find((m==1))) serie=ratio(i,:); % serie de dimension 1 x 220 jours seuil=s(i,1); %the summer ratio level (summer delta tb level) is used as a ratio threshold for detecting first day of snow %2009dec13, spi, begin %jour1neige=[]; %2009dec13, spi, end %while ratio is greater than the threshold, first day of snow has not arrived yet (increment the first day of snow doy variable herein named jour1neige) if (serie(1,1) > seuil && serie(1,2) > seuil && serie(1,3) > seuil) %spi, arnaud mialon's thesis presents this condition: the ratio serie (delta tb serie) must be greater than threshold for 4 consecutive days, herein implementation uses only 3 consecutive days, this number of consecutive days could be adjusted differently for smmr ratios versus ssmi ratios ijour=1; while (serie(1,ijour) > seuil && serie(1,ijour+1) > seuil && serie(1,ijour+2) > seuil ) ijour=ijour+1; if ijour==nbrejour+1-3 %if ijour==218 ijour=-10; break; end end%while if ijour==-10 jour1neige=-10; else jour1neige=ijour+1; end else jour1neige=-10; end%if (serie(1,1) > seuil seriej1=[seriej1;jour1neige]; end%i = 1: d1 jour1(indmask,1)=seriej1; jour1=reshape(jour1,dim(1),dim(2)); %% enregistrement de la matrice chemin=[pathratio,filesep,'ratio_',zone,filesep,'fichier_jdjf ',filesep]; if(~isdir(chemin)) mkdir(chemin); end cd(chemin); nomfichierjour1=['jour1neigeam',int2str(an)]; f_jour1=fopen(nomfichierjour1,'w+'); fwrite(f_jour1,jour1,'int16'); fclose(f_jour1); clear f_jour1; cd(prevdir); end%function