Changeset 21917


Ignore:
Timestamp:
08/08/17 17:34:18 (8 years ago)
Author:
schlegel
Message:

CHG: add capability for more than one climatology to be passed in

Location:
issm/trunk-jpl/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Elements/Element.cpp

    r21895 r21917  
    539539        IssmDouble Delta18oTime;
    540540        IssmDouble dpermil,f;
    541         IssmDouble time,yts,time_yr,month;
     541        IssmDouble time,yts,time_yr,month,time_clim;
    542542        this->parameters->FindParam(&time,TimeEnum);
    543543        this->parameters->FindParam(&yts,ConstantsYtsEnum);
    544544        this->parameters->FindParam(&f,SmbFEnum);
    545545        time_yr=floor(time/yts)*yts;
     546        time_clim=time_yr;
    546547
    547548        /*Get some pdd parameters*/
     
    551552        Input*     input=this->inputs->GetInput(SmbTemperaturesPresentdayEnum);    _assert_(input);
    552553        Input*     input2=this->inputs->GetInput(SmbPrecipitationsPresentdayEnum); _assert_(input2);
     554        int offset;
     555
     556        offset=dynamic_cast<TransientInput*>(input)->GetTimeInputOffset(time_yr);
     557        if (fmod(offset,12)!=1){
     558                time_clim=floor(dynamic_cast<TransientInput*>(input)->GetTimeByOffset(offset-fmod(offset,12)+1)/yts)*yts;
     559        }
     560
    553561        /*loop over vertices: */
    554562        Gauss* gauss=this->NewGauss();
     
    556564                for(int iv=0;iv<numvertices;iv++) {
    557565                        gauss->GaussVertex(iv);
    558                         input->GetInputValue(&TemperaturesPresentday[iv*12+month],gauss,month/12.*yts);
    559                         input2->GetInputValue(&PrecipitationsPresentday[iv*12+month],gauss,month/12.*yts);
     566                        input->GetInputValue(&TemperaturesPresentday[iv*12+month],gauss,time_clim+month/12.*yts);
     567                        input2->GetInputValue(&PrecipitationsPresentday[iv*12+month],gauss,time_clim+month/12.*yts);
    560568
    561569                        PrecipitationsPresentday[iv*12+month]=PrecipitationsPresentday[iv*12+month]*yts;
  • issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp

    r21872 r21917  
    246246
    247247        delete input;
     248}
     249/*}}}*/
     250int  TransientInput::GetTimeInputOffset(IssmDouble time){/*{{{*/
     251
     252        int        found;
     253        int        offset;
     254
     255        /*go through the timesteps, and figure out which interval we
     256         *     *fall within. Then interpolate the values on this interval: */
     257        found=binary_search(&offset,time,this->timesteps,this->numtimesteps);
     258        if(!found) _error_("Input not found (is TransientInput sorted ?)");
     259
     260        return offset;
     261}
     262/*}}}*/
     263IssmDouble  TransientInput::GetTimeByOffset(int offset){/*{{{*/
     264
     265        if (offset < 0) offset=0;
     266        _assert_(this->timesteps[offset]);
     267
     268        return this->timesteps[offset];
    248269}
    249270/*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h

    r21872 r21917  
    7070                void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime);
    7171                int  GetInputInterpolationType(){_error_("not implemented yet!");};
     72                IssmDouble  GetTimeByOffset(int offset);
    7273                Input* GetTimeInput(IssmDouble time);
     74                int  GetTimeInputOffset(IssmDouble time);
    7375                void GetTimeValues(IssmDouble* values,IssmDouble time){_error_("not implemented yet");};
    7476                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
  • issm/trunk-jpl/src/m/classes/SMBd18opdd.m

    r21710 r21917  
    7676                                md = checkfield(md,'fieldname','smb.rlapslgm','>=',0,'numel',1);
    7777                                if(self.isd18opd==1)
    78                                         md = checkfield(md,'fieldname','smb.temperatures_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1);
    79                                         md = checkfield(md,'fieldname','smb.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1);
     78                                        lent=size(self.temperatures_presentday,2);
     79                                        lenp=size(self.precipitations_presentday,2);
     80                                        multt=ceil(lent/12)*12;
     81                                        multp=ceil(lenp/12)*12;
     82                                        md = checkfield(md,'fieldname','smb.temperatures_presentday','size',[md.mesh.numberofvertices+1 multt],'NaN',1,'Inf',1,'timeseries',1);
     83                                        md = checkfield(md,'fieldname','smb.precipitations_presentday','size',[md.mesh.numberofvertices+1 multp],'NaN',1,'Inf',1,'timeseries',1);
    8084                                        md = checkfield(md,'fieldname','smb.delta18o','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1);
    8185                                        md = checkfield(md,'fieldname','smb.dpermil','>=',0,'numel',1);
  • issm/trunk-jpl/src/m/classes/SMBd18opdd.py

    r21712 r21917  
    9797
    9898                        if self.isd18opd:
    99                                 md = checkfield(md,'fieldname','smb.temperatures_presentday','size',[md.mesh.numberofvertices+1,12],'NaN',1,'Inf',1,'timeseries',1)
    100                                 md = checkfield(md,'fieldname','smb.precipitations_presentday','size',[md.mesh.numberofvertices+1,12],'NaN',1,'Inf',1,'timeseries',1)
     99                                lent=float(np.size(self.temperatures_presentday,1))
     100                                lenp=float(np.size(self.precipitations_presentday,1))
     101                                multt=np.ceil(lent/12.)*12.
     102                                multp=np.ceil(lenp/12.)*12.
     103                                md = checkfield(md,'fieldname','smb.temperatures_presentday','size',[md.mesh.numberofvertices+1,multt],'NaN',1,'Inf',1,'timeseries',1)
     104                                md = checkfield(md,'fieldname','smb.precipitations_presentday','size',[md.mesh.numberofvertices+1,multp],'NaN',1,'Inf',1,'timeseries',1)
    101105                                md = checkfield(md,'fieldname','smb.delta18o','NaN',1,'Inf',1,'size',[2,np.nan],'singletimeseries',1)
    102106                                md = checkfield(md,'fieldname','smb.dpermil','>=',0,'numel',[1])
Note: See TracChangeset for help on using the changeset viewer.