obs_util
Obs Utilities
dropna(df, inplace=True)
remove columns which have all Nans. TO DO: is this needed?
Source code in monetio/obs/obs_util.py
122 123 124 125 | |
find_near(df, latlon, distance=100, sid='site_num', drange=None)
find all values in the df dataframe column sid which are within distance (km) of lat lon point. output dictionary with key as value in column sid and value tuple (latitude, longitude)
Parameters
latlon : tuple or list (longitude, latitude) distance : float kilometers sid: string name of column drange: tuple or list with two datetimes consider rows with dates between these two dates.
Returns
lhash: dictionary key is the value in column sid and value is (latitude, longitude) position.
Source code in monetio/obs/obs_util.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
get_lhash(df, idn)
returns a dictionary with the key as the input column value and the value a tuple of (lat, lon) Useful for getting lat lon locations of different sites in a dataframe.
Source code in monetio/obs/obs_util.py
128 129 130 131 132 133 134 135 136 137 138 139 | |
latlonfilter(df, llcrnr, urcrnr)
removes rows from self.df with latitude longitude outside of the box described by llcrnr (lower left corner) and urcrnr (upper right corner)
Source code in monetio/obs/obs_util.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
summarize(df, verbose=False)
prints list of columns. if verbose prints list of unique values in each column
Source code in monetio/obs/obs_util.py
142 143 144 145 146 147 148 149 150 151 152 | |
timefilter(df, daterange, inplace=True)
removes rows with dates outside of the daterange from self.df
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
daterange
|
|
required | |
inplace
|
|
True
|
Source code in monetio/obs/obs_util.py
182 183 184 185 186 187 188 189 190 191 192 193 | |
write_datem(df, obscolumn='obs', dname='datemfile.txt', sitename='1', info=None, drange=None)
returns string in datem format (See NOAA ARL). datem format has the following columns: Year, Month, Day, Hour, Duration, lat, lon, Concentration (units), site id, height
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obscolumn
|
string
|
name of column with values to write in the Concentration column. |
'obs'
|
dname
|
string
|
|
'datemfile.txt'
|
sitename
|
string.
|
|
'1'
|
info
|
string
|
will be written to the second line of the header. |
None
|
drange
|
list of two time stamp objects.
|
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
runstring |
string
|
string in datem format. |
Source code in monetio/obs/obs_util.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |