1
1
"""
2
- Import TMY2 and TMY3 data.
2
+ Import functions for TMY2 and TMY3 data files .
3
3
"""
4
4
5
5
import logging
@@ -25,33 +25,31 @@ def readtmy3(filename=None, coerce_year=None, recolumn=True):
25
25
'''
26
26
Read a TMY3 file in to a pandas dataframe.
27
27
28
- Read a TMY3 file and make a pandas dataframe of the data. Note that values
29
- contained in the metadata dictionary are unchanged from the TMY3 file (i.e. units
28
+ Note that values contained in the metadata dictionary are
29
+ unchanged from the TMY3 file (i.e. units
30
30
are retained). In the case of any discrepencies between this
31
- documentation and the TMY3 User's Manual ( [1]) , the TMY3 User's Manual
31
+ documentation and the TMY3 User's Manual [1], the TMY3 User's Manual
32
32
takes precedence.
33
33
34
34
Parameters
35
35
----------
36
-
37
36
filename : None or string
38
- If None, attempts to use an interactive file browser.
37
+ If None, attempts to use a Tkinter file browser.
39
38
A string can be a relative file path, absolute file path,
40
39
or url.
41
40
42
41
coerce_year : None or int
43
- If supplied, the year of the data will be coerced to this input .
42
+ If supplied, the year of the data will be set to this value .
44
43
45
44
recolumn : bool
46
45
If True, apply standard names to TMY3 columns.
47
- Typically this resulsts in stripping the units from the column name.
46
+ Typically this results in stripping the units from the column name.
48
47
49
-
50
48
Returns
51
49
-------
52
-
50
+ Tuple of the form (data, metadata).
51
+
53
52
data : DataFrame
54
-
55
53
A pandas dataframe with the columns described in the table below.
56
54
For more detailed descriptions of each component, please consult
57
55
the TMY3 User's Manual ([1]), especially tables 1-1 through 1-6.
@@ -62,6 +60,8 @@ def readtmy3(filename=None, coerce_year=None, recolumn=True):
62
60
Notes
63
61
-----
64
62
63
+ The returned structures have the following fields.
64
+
65
65
=============== ====== ===================
66
66
key format description
67
67
=============== ====== ===================
@@ -251,73 +251,58 @@ def _recolumn(tmy3_dataframe, inplace=True):
251
251
return tmy3_dataframe .rename (columns = mapping , inplace = True )
252
252
253
253
254
-
255
- #########################
256
- #
257
- # TMY2 below
258
- #
259
- #########################
260
-
261
-
262
254
263
255
def readtmy2 (filename ):
264
256
'''
265
- Read a TMY2 file in to a DataFrame
257
+ Read a TMY2 file in to a DataFrame.
266
258
267
- Note that valuescontained in the DataFrame are unchanged from the TMY2
268
- file (i.e. units are retained). Time/Date and Location data imported from the
259
+ Note that values contained in the DataFrame are unchanged from the TMY2
260
+ file (i.e. units are retained). Time/Date and location data imported from the
269
261
TMY2 file have been modified to a "friendlier" form conforming to modern
270
262
conventions (e.g. N latitude is postive, E longitude is positive, the
271
263
"24th" hour of any day is technically the "0th" hour of the next day).
272
264
In the case of any discrepencies between this documentation and the
273
- TMY2 User's Manual ([1]), the TMY2 User's Manual takes precedence.
274
-
275
- If a filename is not provided, the user will be prompted to browse to
276
- an appropriate TMY2 file.
265
+ TMY2 User's Manual [1], the TMY2 User's Manual takes precedence.
277
266
278
267
Parameters
279
268
----------
280
- filename : string
281
-
282
- an optional argument which allows the user to select which
283
- TMY2 format file should be read. A file path may also be necessary if
284
- the desired TMY2 file is not in the working path. If filename
285
- is not provided, the user will be prompted to browse to an
286
- appropriate TMY2 file.
269
+ filename : None or string
270
+ If None, attempts to use a Tkinter file browser.
271
+ A string can be a relative file path, absolute file path,
272
+ or url.
287
273
288
274
Returns
289
275
-------
276
+ Tuple of the form (data, metadata).
277
+
278
+ data : DataFrame
279
+ A dataframe with the columns described in the table below.
280
+ For a more detailed descriptions of each component, please consult
281
+ the TMY2 User's Manual ([1]), especially tables 3-1 through 3-6, and
282
+ Appendix B.
290
283
291
- TMYData : DataFrame
292
-
293
- A dataframe, is provided with the following components. Note
294
- that for more detailed descriptions of each component, please consult
295
- the TMY2 User's Manual ([1]), especially tables 3-1 through 3-6, and
296
- Appendix B.
297
-
298
- meta : struct
299
-
300
- A struct containing the metadata from the TMY2 file.
284
+ metadata : dict
285
+ The site metadata available in the file.
301
286
302
287
Notes
303
288
-----
304
289
305
- The structures have the following fields
290
+ The returned structures have the following fields.
306
291
307
- ============================ ============================================================
308
- meta Field
309
- ============================ ========================== ==================================
310
- meta. SiteID Site identifier code (WBAN number), scalar unsigned integer
311
- meta. StationName Station name, 1x1 cell string
312
- meta. StationState Station state 2 letter designator, 1x1 cell string
313
- meta. SiteTimeZone Hours from Greenwich, scalar double
314
- meta. latitude Latitude in decimal degrees, scalar double
315
- meta. longitude Longitude in decimal degrees, scalar double
316
- meta. SiteElevation Site elevation in meters, scalar double
317
- ============================ ========================== ==================================
292
+ ============= ==================================
293
+ key description
294
+ ============= ==================================
295
+ SiteID Site identifier code (WBAN number)
296
+ StationName Station name
297
+ StationState Station state 2 letter designator
298
+ SiteTimeZone Hours from Greenwich
299
+ latitude Latitude in decimal degrees
300
+ longitude Longitude in decimal degrees
301
+ SiteElevation Site elevation in meters
302
+ ============= ==================================
318
303
319
304
============================ ==========================================================================================================================================================================
320
- TMYData Field Meaning
305
+ TMYData field description
321
306
============================ ==========================================================================================================================================================================
322
307
index Pandas timeseries object containing timestamps
323
308
year
@@ -399,7 +384,7 @@ def readtmy2(filename):
399
384
for TMY2s". NREL 1995.
400
385
'''
401
386
402
- if filename is None : #If no filename is input
387
+ if filename is None :
403
388
try :
404
389
filename = _interactive_load ()
405
390
except :
0 commit comments