[SciPy-user] scikits.timeseries : masking data after it has been read in using tsfromtxt

Pierre GM pgmdevlist@gmail....
Wed Jun 17 13:44:47 CDT 2009


On Jun 17, 2009, at 11:43 AM, Dharhas Pothina wrote:

>
> SB1S =  
> ts 
> .tsfromtxt 
> ('SB1S 
> .txt 
> ',freq 
> = 
> 'T 
> ',comments 
> ='#',dateconverter=dateconverter,datecols=(0,1,2,3,4),usecols  
> = 
> (0,1,2,3,4,7,9,8),names='Y,M,D,hh,mm,Temperature,Salinity,WaterLevel')
>
> I want to perform some extra masking. ie mask all salinities below 0  
> and above 100, mask all temperatures = -999 etc

Dharhas,
Here's an example:

 >>> ndtype = [('T', '<f8'), ('S', '<f8')]
 >>> series = ts.time_series(zip(np.arange(12),np.arange(12)),
 >>>                         dtype=ndtype,
 >>>                         start_date=ts.now('M'))
 >>> print series
 >>> # Mask all the records for which 'T' < 5
 >>> series[series['T']<5] = ma.masked
 >>> print series
 >>> # Mask field 'S' if 'S' is even
 >>> s = series['S']
 >>> s[s%2==0] = ma.masked
 >>> print series

As you can see, you can mask whole records or individual fields,  
depending on what you want.





More information about the SciPy-user mailing list