Home > . > jdjf.m

jdjf

PURPOSE ^

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function [jdebut,jfin]=jdjf(dataset,an,ratiosansfiltre,ratiofiltre,seuil1,seuil2,nbrejour)

DESCRIPTION ^

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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

nakedsoftware.org opensource license, copyright 2010 stephane.poirier@oifii.org 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
version 0.2    spi, 2008mai15 patch, SMMR last year combine with SSMI first year
version 0.2    jdjf(dataset,an,ratiosansfiltre,ratiofiltre,seuil1,seuil2,nbrejour)
version 0.1    jdjf(ratiosansfiltre,ratiofiltre,seuil,nbrejour)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 %nakedsoftware.org opensource license, copyright 2010 stephane.poirier@oifii.org
0003 %
0004 %developed by Stephane Poirier, M.Sc. Optical Physics, Remote Sensing Application Software Developer (1991-2010)
0005 %
0006 %this function is part of oifii.org's ar\sp\ Microwave-derived 30-year Canada-Alaska Daily Temperature and Snowcover Databases library
0007 %
0008 %this function is part of oifii.org's ar\sp\'this folder' application (lauched with ar\sp\'this file'.m)
0009 %oifii.org's ar\sp\affiche_carte application is part of the oifii.org's ar\sp set of applications which
0010 %may also contain similar variant versions of this function with identical filename.
0011 %
0012 %A geophysical research paper about this work has been submitted in June 2009 for publication in JGR-Atmosphere
0013 %Royer, A. and Poirier S., Surface temperature spatial and temporal variations in North America from homogenized
0014 %satellite SMMR-SSM/I microwave measurements and reanalysis for 1979-2008, Journal of Geophysical Research - Atmosphere,
0015 %Submitted June 2009, http://www.oifii.org/tsatdb/Royer-Poirier_Microwave-derived-daily-surface-temperature_JGR2009JD012760_R2.pdf
0016 %
0017 %This study's database can be downloaded from the author web site at:
0018 %http://www.oifii.org/tsatdb/Royer-Poirier_Microwave-derived-daily-surface-temperature-db_1979-2008.zip
0019 %
0020 %this function is used to display the raw microwave raster data (NSIDC's SMMR and SSMI satellite, ref. nsidc.org)
0021 %
0022 %usage:
0023 %       20yymmmdd
0024 %
0025 %version 0.0, 20yymmmdd, spi, initial function draft
0026 %
0027 %nakedsoftware.org opensource license, copyright 2010 stephane.poirier@oifii.org
0028 %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 %version 0.2    spi, 2008mai15 patch, SMMR last year combine with SSMI first year
0030 %version 0.2    jdjf(dataset,an,ratiosansfiltre,ratiofiltre,seuil1,seuil2,nbrejour)
0031 %version 0.1    jdjf(ratiosansfiltre,ratiofiltre,seuil,nbrejour)
0032 function [jdebut,jfin]=jdjf(dataset,an,ratiosansfiltre,ratiofiltre,seuil1,seuil2,nbrejour)
0033 seuil=seuil1;
0034 if isnan(seuil)
0035     jdebut=1;
0036     jfin=nbrejour;
0037     return;
0038 end
0039 %-------------------%
0040 % jour debut ete    %
0041 %-------------------%
0042 days_1erepartie=[1:200]; % definition des limites pour la premiere partie de l'annee
0043 ratio=ratiofiltre(days_1erepartie);
0044 rssf=ratiosansfiltre(days_1erepartie);
0045 jourvalid=days_1erepartie(~isnan(rssf));
0046 ratiovalid=ratio(~isnan(rssf));
0047 rssf=rssf(~isnan(rssf));
0048 if ~isempty(jourvalid) & ~isempty(ratiovalid)
0049     % Points pour l'interpolation linéaire (si nécessaire)
0050     x=[];
0051     y=[];
0052     tbSetMaxCount=3;
0053     index=length(ratiovalid);
0054     ratioX=ratiovalid(index);
0055     indexRatioY=[];
0056     moyplsjour=[];
0057     condition=0;
0058     while (ratioX>=seuil | condition==0) & index>3
0059         if ratioX>=seuil
0060             moyplsjour=[];
0061             indexRatioY=index;
0062         else
0063             serieplsratio=[];
0064             serieplsratio=ratiovalid(index-3:index);
0065             moyplsjour=rssf(1:index);
0066             moyplsjour(isnan(moyplsjour))=[];
0067             if (length(moyplsjour)-7)>0
0068                 ind1=length(moyplsjour)-7;
0069             elseif length(moyplsjour)-7<=0
0070                 ind1=1;
0071             end
0072             moyplsjour=moyplsjour(ind1:length(moyplsjour));
0073             if length(serieplsratio)>=tbSetMaxCount
0074                 moyplsjour;
0075                 d=length(find(moyplsjour<seuil))/length(moyplsjour);
0076                 if d>=0.5
0077                     condition=1;
0078                 else
0079                     condition=0;
0080                 end
0081             else
0082                 condition=0;
0083             end
0084         end
0085         index=index-1;
0086         ratioX=ratiovalid(index);
0087     end % fin while ratioX >= seuil & index ~= 1
0088     if ratioX<=seuil
0089         if ~isempty(indexRatioY)
0090             x=[jourvalid(indexRatioY-1) jourvalid(indexRatioY)];
0091             y=[ratiovalid(indexRatioY-1) ratiovalid(indexRatioY)];
0092         else
0093             jdebut=1;
0094         end
0095     else
0096         jdebut=1;
0097     end % fin de condition ratioX <= seuil
0098     % Interpolation linéaire (si nécessaire)
0099     if ~isempty(x) & ~isempty(y)
0100         fraction=(seuil-y(1))/(y(2)-y(1));
0101         jdebut=round(x(1)+fraction*(x(2)-x(1)));
0102     end
0103     clear x y jourvalid ratiovalid ratio index fraction ratioX;
0104 end % fin de condition ~isempty(jourvalid) & ~isempty(ratiovalid)
0105 
0106 %--------------------------%
0107 %      JOUR FIN ETE        %
0108 %--------------------------%
0109 version=2;
0110 jourdebut_2emepartie=225;
0111 if((dataset==1)&&(an==1987))
0112     jourdebut_2emepartie=233; %ssmi start
0113     seuil=seuil2; %ssmi threshold
0114 end
0115 if version==2
0116     % Jour fin été version 2
0117     days_2emepartie=[jourdebut_2emepartie:nbrejour];
0118     ratio=ratiofiltre(days_2emepartie);
0119     rssf=[];
0120     rssf=ratiosansfiltre(days_2emepartie);
0121     jourvalid=days_2emepartie(~isnan(ratio));
0122     ratiovalid=ratio(~isnan(ratio));
0123     rssf=rssf(~isnan(ratio));
0124     if ~isempty(jourvalid) & ~isempty(ratiovalid) %poirier, pour annee 1987, jourvalid un vecteur de 8 jours (232-225) qui ne contient que des NaN
0125         % Points pour l'interpolation linéaire (si nécessaire)
0126         x=[];
0127         y=[];
0128         tbSetMaxCount=3;
0129         index=length(ratiovalid);
0130         ratioX=ratiovalid(index);
0131         indexRatioY=[];
0132         condition=0;
0133         while (ratioX<seuil | condition==0) & index>3
0134             if ratioX<seuil
0135                 indexRatioY=index;
0136             else
0137                 serieplsratio=[];
0138                 if index>3
0139                     serieplsratio=ratiovalid(index-3:index);
0140                 else
0141                     serieplsratio=ratiovalid(1:index);
0142                 end
0143                 serieplsratio(isnan(serieplsratio))=[];
0144                 d=length(find(serieplsratio>seuil))/length(serieplsratio);
0145                 if d>=0.5
0146                     condition=1;
0147                 else
0148                     condition=0;
0149                 end
0150             end
0151             index=index-1;
0152             ratioX=ratiovalid(index);
0153         end
0154         if ratioX>seuil
0155             if ~isempty(indexRatioY)
0156                 x=[jourvalid(indexRatioY-1) jourvalid(indexRatioY)];
0157                 y=[ratiovalid(indexRatioY-1) ratiovalid(indexRatioY)];
0158             else
0159                 jfin=nbrejour;
0160             end
0161         else
0162             jfin=nbrejour;
0163         end % fin de condition ratioX <= seuil
0164         % Interpolation linéaire (si nécessaire)
0165         if ~isempty(x) & ~isempty(y)
0166             fraction=(seuil-y(1))/(y(2)-y(1));
0167             jfin=round(x(1)+fraction*(x(2)-x(1)));
0168         end
0169         clear x y jourvalid ratiovalid ratio index fraction ratioX;
0170     end % fin de condition ~isempty(jourvalid) & ~isempty(ratiovalid)
0171 elseif version==1
0172     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0173     % Jour fin été version 1
0174     days_2emepartie=[jourdebut_2emepartie:nbrejour];
0175     ratio=ratiofiltre(days_2emepartie);
0176     rssf=[];
0177     rssf=ratiosansfiltre(days_2emepartie);
0178     jourvalid=days_2emepartie(~isnan(ratio));
0179     ratiovalid=ratio(~isnan(ratio));
0180     rssf=rssf(~isnan(ratio));
0181     if ~isempty(jourvalid) & ~isempty(ratiovalid)
0182         % Points pour l'interpolation linéaire (si nécessaire)
0183         x=[];
0184         y=[];
0185         tbSetMaxCount=3;
0186         index=1;
0187         ratioX=ratiovalid(index);
0188         count=0;
0189         indexRatioY=[];
0190         moyplsjour=[];
0191         condition=0;
0192         while (ratioX>=seuil | condition==0) & index~=(length(ratiovalid))
0193             if ratioX>=seuil
0194                 indexRatioY=index;
0195                 moyplsjour=[];
0196             else
0197                 serieplsratio=[];
0198                 if index<=length(ratiovalid)-3
0199                     serieplsratio=ratiovalid(index:index+3);
0200                 else
0201                     serieplsratio=ratiovalid(index: ...
0202                         length(ratiovalid));
0203                 end
0204                 serieplsratio(isnan(serieplsratio))=[];
0205                 %moyplsjour = rssf(index:length(ratiovalid)) ;
0206                 %moyplsjour(isnan(moyplsjour)) = [] ;
0207                 %if length(moyplsjour) >= 4
0208                 %   ind2 = 4 ;
0209                 %else
0210                 %      ind2 = length(moyplsjour) ;
0211                 %       end
0212                 %      moyplsjour = moyplsjour(1:ind2);
0213                 %if length(serieplsratio)>=tbSetMaxCount
0214                 d=length(find(serieplsratio<seuil))/length(serieplsratio);
0215                 %d = length(find(moyplsjour<seuil)) / length(moyplsjour);
0216                 if d>=0.5
0217                     condition=1;
0218                 else
0219                     condition=0;
0220                 end
0221                 %else
0222                 %       condition = 0 ;
0223                 %     end
0224             end
0225             index=index+1;
0226             ratioX=ratiovalid(index);
0227         end
0228         %     while (ratioX >= seuil | count < tbSetMaxCount) & index ~= length(ratiovalid)
0229         %            if ratioX >= seuil
0230         %              indexRatioY = index;
0231         %              count = 0;
0232         %            else
0233         %              count = count + 1;
0234         %            end
0235         %            index  = index + 1;
0236         %            ratioX = ratiovalid(index);
0237         %     end % fin de boucle while
0238         if ratioX<=seuil
0239             if ~isempty(indexRatioY)
0240                 x=[jourvalid(indexRatioY) jourvalid(indexRatioY+1)];
0241                 y=[ratiovalid(indexRatioY) ratiovalid(indexRatioY+1)];
0242             else
0243                 jfin=nbrejour;
0244             end
0245         else
0246             jfin=nbrejour;
0247         end % fin de condition ratioX <= seuil
0248         % Interpolation linéaire (si nécessaire)
0249         if ~isempty(x)&~isempty(y)
0250             fraction=(seuil-y(1))/(y(2)-y(1));
0251             jfin=round(x(1)+fraction*(x(2)-x(1)));
0252         end
0253         clear x y jourvalid ratiovalid ratio index fraction ratioX;
0254     end % fin de condition ~isempty(jourvalid) & ~isempty(ratiovalid)
0255     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0256 end %version
0257 %figure
0258 %plot([1:length(ratiofiltre)],ratiofiltre,'-+k',...
0259 %    [1 length(ratiosansfiltre)],[seuil seuil],'--k',...
0260 %    'color',[0.4 0.4 0.4],...
0261 %   'LineWidth',1);
0262 %hold on ;
0263 %plot([1:length(ratiosansfiltre)],ratiosansfiltre,'+k');
0264 %hold on ;
0265 %plot([jdebut jdebut],[min(ratiosansfiltre) max(ratiosansfiltre)],':k',...
0266 %    [jfin jfin],[min(ratiosansfiltre) max(ratiosansfiltre)],':k');
0267 end%function

Generated on Thu 28-Jan-2010 14:04:46 by m2html © 2003