nrgpy package¶
Submodules¶
nrgpy.api_connect module¶
-
nrgpy.api_connect.
load_token
(filename='.nrgpy_token')¶ read session token from pickle file
-
nrgpy.api_connect.
maintain_session_token
(client_id='', client_secret='', filename='.nrgpy_token')¶ maintain a current/valid session token for data service api
-
nrgpy.api_connect.
request_session_token
(client_id='', client_secret='')¶ generates a new session token for convert service api
requires an active account with NRG Systems. to sign up for an account, go to: https://services.nrgsystems.com
- Parameters
client_id (str) – obtained from NRG Systems
client_secret (str) –
- Returns
session_token (str) – valid for 24 hour
session_start_time (datetime) – start time of 24 hour countdown
-
nrgpy.api_connect.
save_token
(session_token, session_start_time, filename='.nrgpy_token')¶ save session token in token pickle file
-
nrgpy.api_connect.
token_valid
(session_start_time)¶ check if token is still valid
- Parameters
session_start_time (datetime) – generated at time of token request
- Returns
status – true if still valid, false if expired
- Return type
bool
nrgpy.channel_info_arrays module¶
-
nrgpy.channel_info_arrays.
return_array
(data_file_type)¶ return data file header parameter array based on data_file_type
-
nrgpy.channel_info_arrays.
return_sp3_ch_info
()¶ returns array of sensor info parameters for Symphonie, PLUS, and PLUS3 txt export files
-
nrgpy.channel_info_arrays.
return_spro_ch_info
()¶ returns array of possible channel parameters for SymphoniePRO txt export files
nrgpy.convert_rld module¶
-
class
nrgpy.convert_rld.
local
(rld_dir='', out_dir='', encryption_pass='', hex_key='', filename='', sympro_path='"C:/Program Files (x86)/Renewable NRG Systems/SymPRO Desktop/SymPRODesktop.exe"', process_type='convert', convert_type='meas', nec='', site_filter='', site_file='', **kwargs)¶ Bases:
object
For handling NRG SymphoniePRO Data Logger raw data files in the *.rld format.
This method uses locally installed SymphoniePRO Desktop software to convert *.rld files to txt format (tab-delimited-text).
- Parameters
rld_dir (str, optional) – specify directory. Note for unc values, you will need to escape all forward slashes, e.g. rld_dir = “\soltechsupportdata" or use the r’path odir’ approach
out_dir (str, optional) – see note for rld_dir.
encryption_pass (str) – specify data encryption password if logger is set up for that.
hex_key (str) – specify if using hex data encryption key
sympro_path (str) – default is “C:Program Files (x86)Renewable NRG SystemsSymPRO DesktopSymPRODesktop.exe”
process_type (str) – [convert], or import
convert_type (str) – ‘meas’, alternately specify ‘comm’, ‘diag’, ‘sample’, or ‘events’
nec (str) – path to nec file
site_filter (str) – specify part or all of the file you’d like to filter on, like site_filter=’123456_2018-09’ would filter on site 123456 and only the month of September in 2018.
site_file (bool or str) – set to True to use local ndb site file, or set to path to an alternate ndb site file
Examples
Convert a folder of RLD files to Text with SymphoniePRO Desktop Software
>>> from nrgpy.convert_rld import local >>> converter = local( rld_dir='/path/to/rld/files', out_dir=/path/to/txt/outputs, file_filter='123456_2020-01', # for files from January 2020 ) >>> converter.convert()
-
convert
()¶
-
directory
()¶ processes all rld files in self.rld_dir, outputs to txt files to out_dir
-
process
()¶
-
rename_rlds
(**kwargs)¶ uses SymPRO utility NrgRldSiteSerialRename.exe to rename files with site number and logger serial number.
This function is only compatible with Windows>=7 AND a local installation of SymphoniePRO Desktop software
-
single_file
(filepath='')¶
nrgpy.convert_rwd module¶
-
class
nrgpy.convert_rwd.
local
(rwd_dir='', out_dir='', filename='', encryption_pin='', sdr_path='C:/NRG/SymDR/SDR.exe', convert_type='meas', file_filter='', wine_folder='~/.wine/drive_c/', use_site_file=False, raw_mode=False, progress_bar=True, show_result=True, **kwargs)¶ Bases:
object
nrgpy.convert_rwd.local - use local installation of Symphonie Data Retriever (SDR) to convert *.RWD files to *.TXT
- Parameters
filename (str) – if populated, a single file is exported
encryption_pin (str) – four digit pin, only used for encrypted files
sdr_path (str) – r‘“C:/NRG/SymDR/SDR.exe”’, may be any path
file_filter (str) – filters files on text in filename
rwd_dir (str) – folder to check for RWD files
out_dir (str) – folder to save exported TXT files into
wine_folder (str) – ‘~/.wine/drive_c/’, for linux installations
use_site_file (bool) – set to True to use local site file
raw_mode (bool) – set to True to convert raw counts and voltages
progress_bar (bool) – set to False to see individual file conversions
show_result (bool) – set to False to hide prints to console
- Returns
- Return type
None
Examples
Convert a folder of RWD files to Text with SymphoniePRO Desktop Software
>>> from nrgpy.convert_rwd import local >>> converter = local( rwd_dir='/path/to/rwd/files', out_dir=/path/to/txt/outputs, file_filter='1234202001', # for files from January 2020 )
>>> converter.convert()
Convert a folder … on Linux; this assumes you followed the instructions in the ‘’’SDR_Linux_README.md’’’ file.
>>> import getpass >>> import nrgpy
>>> username = getpass.getuser()
>>> rwd_dir = f"/home/{username}/data/symplus3/raw" >>> txt_dir = f"/home/{username}/data/symplus3/export" >>> wine_folder = f"/home/{username}/prefix32/drive_c"
>>> converter = nrgpy.convert_rwd.local( rwd_dir=rwd_dir, out_dir=txt_dir, wine_folder=wine_folder )
>>> converter.convert()
-
check_sdr
()¶ determine if SDR is installed
-
convert
()¶ process rwd files
create list of RWD files that match filtering copy RWD files to RawData directory iterate through files
nrgpy.ipk2lgr module¶
-
nrgpy.ipk2lgr.
callinterval
(original)¶
-
nrgpy.ipk2lgr.
calltime
(original)¶
-
nrgpy.ipk2lgr.
ipackinfo
(typeint)¶
-
nrgpy.ipk2lgr.
ipackinfo_backup
(phonestr)¶
-
nrgpy.ipk2lgr.
ipk2lgr
(ipkfile)¶
nrgpy.nrg_api module¶
-
class
nrgpy.nrg_api.
nrg_api
(client_id='', client_secret='')¶ Bases:
object
Parent class for NRG API functionality
-
load_token
(filename='.nrgpy_token')¶ read session token from pickle file
-
maintain_session_token
(filename='.nrgpy_token')¶ maintain a current/valid session token for data service api
-
prepare_file_bytes
(filename='')¶
-
request_session_token
()¶ generates a new session token for convert service api
requires an active account with NRG Systems. to sign up for an account, go to: https://services.nrgsystems.com
- Parameters
client_id (str) – obtained from NRG Systems
client_secret (str) –
- Returns
session_token (str) – valid for 24 hour
session_start_time (datetime) – start time of 24 hour countdown
-
save_token
(filename='.nrgpy_token')¶ save session token in token pickle file
-
token_valid
()¶ check if token is still valid
- Parameters
session_start_time (datetime) – generated at time of token request
- Returns
status – true if still valid, false if expired
- Return type
bool
-
-
class
nrgpy.nrg_api.
nrg_api_catalog
(serial_number='', site_number='', start_date='2014-01-01', end_date='2023-12-31', client_id='', client_secret='', **kwargs)¶ Bases:
nrgpy.nrg_api.nrg_api
Uses NRG hosted web-based API to catalog of available data in text format To sign up for the service, go to https://services.nrgsystems.com/
- Parameters
serial_number (str or int) – serial number of data logger (like, 820612345)
site_number (str or int) – up to 6-digit site number
start_date (str) – “YYYY-MM-DD HH:MM:SS” format, if just date it will return the whole day times are in logger local time
end_date (str) – “YYYY-MM-DD HH:MM:SS” format, if just date it will return the whole day times are in logger local time
client_id (str) – provided by NRG Systems
client_secret (str) – provided by NRG Systems
- Returns
export object
- Return type
object
Examples
Check for available data files for site number 6
>>> import nrgpy >>> client_id = "contact support@nrgsystems.com for access" >>> client_secret = "contact support@nrgsystems.com for access" >>> catalog = nrgpy.nrg_api_catalog( client_id=client_id, client_secret=client_secret, site_number=6, serial_number=820600019, start_date="2020-05-01", end_date="2020-05-03", save_file=False )
-
data_catalog
()¶
-
class
nrgpy.nrg_api.
nrg_api_convert
(rld_dir='', out_dir='', filename='', site_filter='', filter2='', start_date='1970-01-01', end_date='2150-12-31', client_id='', client_secret='', encryption_pass='', header_type='standard', nec_file='', export_type='meas', export_format='csv_zipped', progress_bar=True, **kwargs)¶ Bases:
nrgpy.nrg_api.nrg_api
Uses NRG hosted web-based API to convert RLD files text format To sign up for the service, go to https://services.nrgsystems.com/
- Parameters
rld_dir (str) – path to rld file directory
out_dir (str) – path to save text export files
filename (str) – provide for single file conversion
site_filter (str, optional) – text filter for limiting file set
filter2 (str, optional) – another text filter…
start_date (str, optional) – text start date to filter on “YYYY-mm-dd”
end_date (str, optional) – text end date to filter on “YYYY-mm-dd”
client_id (str) – provided by NRG Systems
client_secret (str) – provided by NRG Systems
token (str) – deprecated, for beta conversion service users
encryption_pass (str, optional) – password for rld files (set in logger)
header_type (str) – [standard], columnonly, or none
nec_file (str, optional) – path to NEC file for custom export formatting
export_type (str) – [meas], samples, diag, comm
Examples
Convert a single RLD file to Text with NRG Convert API
>>> import nrgpy >>> filename = "/home/user/data/sympro/000123/000123_2019-05-23_19.00_003672.rld >>> client_id = "contact support@nrgsystems.com for access" >>> client_secret = "contact support@nrgsystems.com for access" >>> converter = nrgpy.nrg_api_convert( file_filter=file_filter, filename=filename, client_id=client_id, client_secret=client_secret, )
Convert a folder of RLD files to Text with NRG Convert API
>>> import nrgpy >>> file_filter = "000175" >>> rld_directory = "rlds" >>> txt_dir = "/home/user/data/sympro/000123/txt/" >>> client_id = "contact support@nrgsystems.com for access" >>> client_secret = "contact support@nrgsystems.com for access" >>> converter = nrgpy.nrg_api_convert( file_filter=file_filter, rld_dir=rld_directory, out_dir=txt_dir, client_id=client_id, client_secret=client_secret, start_date="2020-01-01", end_date="2020-01-31", ) >>> converter.process()
-
process
()¶
-
single_file
(rld)¶
-
class
nrgpy.nrg_api.
nrg_api_export
(out_dir='', serial_number='', site_number='', start_date='2014-01-01', end_date='2023-12-31', client_id='', client_secret='', nec_file='', save_file=True, **kwargs)¶ Bases:
nrgpy.nrg_api.nrg_api
Uses NRG hosted web-based API to download data in text format To sign up for the service, go to https://services.nrgsystems.com/
- Parameters
out_dir (str) – path to save exported data
out_file (str) – (optional) filename to save
serial_number (str or int) – serial number of data logger (like, 820612345)
site_number (str or int) – up to 6-digit site number
start_date (str) – “YYYY-MM-DD HH:MM:SS” format, if just date it will return the whole day times are in logger local time
end_date (str) – “YYYY-MM-DD HH:MM:SS” format, if just date it will return the whole day times are in logger local time
client_id (str) – provided by NRG Systems
client_secret (str) – provided by NRG Systems
save_file (bool) – (True) whether to save the result to file
nec_file (str, optional) – path to NEC file for custom export formatting
- Returns
export object that includes an nrgpy reader object
- Return type
object
Examples
Download 3 days of data with an NEC file applied
>>> import nrgpy >>> client_id = "contact support@nrgsystems.com for access" >>> client_secret = "contact support@nrgsystems.com for access" >>> exporter = nrgpy.nrg_api_export( client_id=client_id, client_secret=client_secret, out_dir=txt_dir, nec_file='12vbat.nec', site_number=6, serial_number=820600019, start_date="2020-05-01", end_date="2020-05-03", save_file=False ) >>> reader = exporter.reader >>> reader.format_site_data() >>> if reader: >>> print(f"Site number : {reader.site_number}") >>> print(f"Site description : {reader.site_description}") >>> reader.interval_check = nrgpy.check_intervals(reader.data) >>> else: >>> print("unable to get reader")
-
export
()¶
-
class
nrgpy.nrg_api.
nrg_api_upload
(client_id='', client_secret='', filename='', rld_dir='', site_filter='', site_filter2='', start_date='1970-01-01', end_date='2150-12-31')¶ Bases:
nrgpy.nrg_api.nrg_api
-
upload_directory
(progress_bar=True)¶
-
upload_file
()¶
-
nrgpy.nsd_functions module¶
-
class
nrgpy.nsd_functions.
nsd
(nsd_file='')¶ Bases:
object
class for handling NSD files from Symphonie Logger Data.
- Parameters
nsd_file (str) – path to nsd file to open for reading and writing
- Returns
- Return type
obj
Example
>>> from nrgpy.nsd_functions import nsd
>>> db = nsd(nsd_file="C:/NRG/SiteFiles/0322.nsd")
>>> db.read_channel_settings(channel=1)
>>> db.channel_settings TimeStamp Channel SensorType SensorDesc SerialNumber Height ScaleFactor Offset PrintPrecision Units SensorDetail SensorNotes 0 1899-12-30 1 1 NRG #40 Anem. m/s SN002618 50 m 0.766 0.332 1 m/s
>>> db.write_channel_settings(channel=1, description="50m CLASS 1 m/s", scale_factor=1, offset=1)
>>> db.read_channel_settings(channel=1)
>>> db.channel_settings TimeStamp Channel SensorType SensorDesc SerialNumber Height ScaleFactor Offset PrintPrecision Units SensorDetail SensorNotes 0 1899-12-30 1 1 50m CLASS 1 m/s SN002618 50 m 1.0 1.0
-
add_channel_history
(timestamp='', channel=0, sensor_type='1', sensor_desc='', print_precision=4, units='', serial_number='', height='', sensor_detail='', sensor_notes='', scale_factor=- 9999, offset=- 9999)¶ use for adding new sensor history registries
- Parameters
timestamp (string) – “YYYY-MM-DD HH:MM:SS”
channel (int) – or string, channel number
sensor_type (int) –
- or string, number:
1 : anemometer 2 : totalizer (rain gauge) 3 : vane 4 : analog (temp, bp, rh, etc.)
sensor_desc (string) – description
print_precision (int) – 1 through 4, number of decimals
units (string) –
serial_number (string) –
height (float) –
sensor_detail (note) –
sensor_notes (note) –
scale_factor (float) –
offset (float) –
-
check_for_jet_drivers
()¶ check for jet database drivers
- Returns
True if drivers present, otherwise False
- Return type
bool
-
check_platform
()¶ determine which operating system python is running on
-
close
()¶ close connection to database
-
read_channel_settings
(channel=0, dash=False)¶ read individual channel settings from sensor history table
- Parameters
channel (int) – 1 through 15 (12 if Sym Classic nsd file)
- Returns
pandas dataframe of channel details
- Return type
obj
-
read_sensor_history
()¶ read SensorHistory table into dataframe
- Returns
sensor_history : pandas dataframe
- Return type
obj
-
write_channel_settings
(channel=0, entry=1, sensor_desc='', print_precision=- 9999, units='', serial_number='', height='', sensor_detail='', sensor_notes='', scale_factor=- 9999, offset=- 9999)¶ write new sensor history to site file
- Parameters
channel (int) – required; 1 through 15 (or 1 through 12 for Sym Classic)
entry (int) – default is 1 for channel baseline values, 2, 3, etc. for newer entries
sensor_desc (string) –
print_precision (int) – 1, 2, 3, or 4 or 0 for off
units (string) –
serial_number (string) –
height (string) –
sensor_detail (string) –
sensor_notes (string) –
scale_factor (float) –
offset (float) –
nrgpy.quality module¶
-
nrgpy.quality.
check_for_missing_txt_files
(txt_file_names)¶ check list of files for missing file numbers
- Parameters
txt_file_names (list) – list of SymphoniePRO text file exports
- Returns
list of “missing” text file numbers
- Return type
list
-
nrgpy.quality.
check_intervals
(df, verbose=True, return_info=False, show_all_missing_timestamps=False, interval='')¶ checks for missing intervals in a pandas dataframe with a “Timestamp” column
- Parameters
df (object) – the dataframe to be checked
interval (int) – [deprecated] the averaging interval in seconds
verbose (bool) – print results to terminal; False to skip
return_info (bool) – set to True to return dict with below values
show_all_missing_timestamps (bool) – set to True to show all missing timestamps in verbose option. otherwise, shows first and last 3.
- Returns
- actual_rows
(int) actual number of rows in data section of export file (1 subtracted for column headers)
- expected_rows
(int) expected number of rows (assumes 10 min. AVG), converts result to whole integer
- time_range
(str) range of time represented in export file
- first_interval
(str) file starting timestamp
- last_interval
(str) file ending timestamp
- missing_timestamps
(list) a list of missing timestamps
- Return type
dict
Examples
ex. pass a reader.data dataframe for an interval check:
>>> reader = nrgpy.sympro_txt_read() instance created, no filename specified >>> reader.concat_txt(txt_dir="C:/data/sympro_data/000110/") ... >>> nrgpy.check_intervals(reader.data, interval=600) Starting timestamp : 2019-01-01 00:00:00 Ending timestamp : 2019-07-01 04:50:00 Data set Duration : 181 days, 4:50:00 Expected rows in data set : 26093 Actual rows in data set : 26093 Data set complete.
-
nrgpy.quality.
find_missing_intervals
(__df, interval)¶ find gaps in data dataframe :returns: a list of all missing intervals :rtype: list
-
nrgpy.quality.
select_interval_length
(df, seconds=True)¶ get interval length of data set
returns the mode of the first 10 intervals of the data set
- Parameters
reader (nrgpy reader object) –
seconds (bool) – (True) set to False to get interval length in minutes
- Returns
- Return type
int
-
nrgpy.quality.
select_mode_from_list
(lst)¶
nrgpy.spidar_txt module¶
-
class
nrgpy.spidar_txt.
spidar_data_read
(filename='')¶ Bases:
object
reads in CSV file(s) using pandas and creates
- Parameters
data_file (str) – path to single CSV or ZIP to be read
directory (str) – path of directory of data_files to concatenate
file_filter (str) – text to filter data files on
- Returns
data (obj) – pandas dataframe of all available data
heights (list) – list of measurement heights
Examples
Read a spidar data file into an object:
>>> import nrgpy >>> reader = nrgpy.spidar_data_read(filename="1922AG0070_CAG70-SPPP-LPPP_PENT_AVGWND_2019-07-04_1.zip") >>> reader.heights ['40', '60', '80', '90', '100', '120', '130', '160', '180', '200']
>>> reader.data Timestamp pressure[mmHg] temperature[C] ... dir_200_mean[Deg] dir_200_std[Deg] wind_measure_200_quality[%] 0 2019-07-03 23:40:00 753.55 23.68 ... 342.36 63.63 48 1 2019-07-03 23:50:00 753.47 23.76 ... 345.70 57.59 38 2 2019-07-04 00:00:00 753.46 23.96 ... 314.16 82.73 20 ...
Ex. read a directory of spidar data files into an object:
>>> reader = nrgpy.spidar_data_read() >>> reader.concat_txt( txt_dir="/path/to/spidardata/", file_filter="2020-01", progress_bar=False ) Adding 1/8 ... /home/user/spidardata/1922AG0070_CAG70-SPPP-LPPP_PENT_AVGWND_2019-07-01_1.zip [OK] Adding 2/8 ... /home/user/spidardata/1922AG0070_CAG70-SPPP-LPPP_PENT_AVGWND_2019-07-01_2.csv [OK] Adding 3/8 ... /home/user/spidardata/1922AG0070_CAG70-SPPP-LPPP_PENT_AVGWND_2019-07-02_1.zip [OK] Adding 4/8 ... /home/user/spidardata/1922AG0070_CAG70-SPPP-LPPP_PENT_AVGWND_2019-07-03_1.zip [OK] Adding 5/8 ... /home/user/spidardata/1922AG0070_CAG70-SPPP-LPPP_PENT_AVGWND_2019-07-04_1.zip [OK] Adding 6/8 ... /home/user/spidardata/1922AG0070_CAG70-SPPP-LPPP_PENT_AVGWND_2019-07-05_1.zip [OK] Adding 7/8 ... /home/user/spidardata/1922AG0070_CAG70-SPPP-LPPP_PENT_AVGWND_2019-07-06_1.zip [OK] Adding 8/8 ... /home/user/spidardata/1922AG0070_CAG70-SPPP-LPPP_PENT_AVGWND_2019-07-07_1.zip [OK] >>> reader.serial_number '1922AG0070'
-
concat_txt
(txt_dir='', output_txt=False, out_file='', file_filter='', file_filter2='', start_date='1970-01-01', end_date='2150-12-31', progress_bar=True)¶
-
get_heights
()¶
-
read_file
(f)¶
nrgpy.sympro_txt module¶
-
nrgpy.sympro_txt.
shift_timestamps
(txt_folder='', out_folder='', file_filter='', start_date='1970-01-01', end_date='2150-12-31', seconds=3600)¶ Takes as input a folder of exported standard text files and time to shift in seconds.
- Parameters
txt_folder (str) – path to folder with txt files to shift
out_folder (str) – where to put the shifted files (in subfolder by default)
file_filter (str) – filter for restricting file set
start_date (str) – date filter “YYYY-mm-dd”
end_date (str) – date filter “YYYY-mm-dd”
seconds (int) – time in seconds to shift timestamps (default 3600)
- Returns
text files with shifted timestamps; new file names include shifted timestamp.
- Return type
obj
-
class
nrgpy.sympro_txt.
sympro_txt_read
(filename='', out_file='', **kwargs)¶ Bases:
object
-
arrange_ch_info
()¶ creates ch_info dataframe and ch_list array
-
calculate_soiling_ratio
(method='IEC', T0=25, G0=1000, alpha=0.0004, I_clean_SC_0=0.9, I_soiled_SC_0=0.9)¶
-
concat_txt
(txt_dir='', file_type='meas', file_filter='', filter2='', start_date='1970-01-01', end_date='2150-12-31', ch_details=False, output_txt=False, out_file='', progress_bar=True, **kwargs)¶ Will concatenate all text files in the txt_dir
files must match the site_filter argument. Note these are both blank by default.
- Parameters
txt_dir (str) – directory holding txt files
file_type (str) – type of export (meas, event, comm, sample, etc…)
file_filter (str) – text filter for txt files, like site number, etc.
filter2 (str) – secondary text filter
start_date (str) – for filtering files to concat based on date “YYYY-mm-dd”
end_date (str) – for filtering files to concat based on date “YYYY-mm-dd”
ch_details (bool) – show additional info in ch_info dataframe
output_txt (bool) – create a txt output of data df
out_file (str) – filename to write data dataframe too if output_txt = True
progress_bar (bool) – show bar on concat [True] or list of files [False]
- Returns
ch_info (obj) – pandas dataframe of ch_list (below) pulled out of file with sympro_txt_read.arrange_ch_info()
ch_list (list) – list of channel info; can be converted to json w/ import json … json.dumps(fut.ch_info)
data (obj) – pandas dataframe of all data
head (obj) – lines at the top of the txt file…, used when rebuilding timeshifted files
site_info (obj) – pandas dataframe of site information
logger_sn (str)
ipack_sn (str)
logger_type (str)
ipack_type (str)
latitude (float)
longitude (float)
elevation (int)
site_number (str)
site_description (str)
start_date (str)
txt_file_names (list) – list of files included in concatenation
Examples
Read files into nrgpy reader object
>>> import nrgpy >>> reader = nrgpy.sympro_txt_read() >>> reader.concat_txt( txt_dir='/path/to/txt/files/', file_filter='123456', # site 123456 start_date='2020-01-01', end_date='2020-01-31', ) Time elapsed: 2 s | 33 / 33 [=============================================] 100% Queue processed >>> reader.logger_sn '820600019' >>> reader.ch_info Bearing: Channel: Description: Effective Date: Height: Offset: Scale Factor: Serial Number: Type: Units: 0 50.00 1 NRG S1 2020-01-31 00:00:00 33.00 0.13900 0.09350 94120000059 Anemometer m/s 1 230.00 2 NRG S1 2020-01-31 00:00:00 0.00 0.13900 0.09350 94120000058 Anemometer m/s 2 50.00 3 NRG S1 2020-01-31 00:00:00 22.00 0.13900 0.09350 94120000057 Anemometer m/s 3 230.00 4 NRG 40C Anem 2020-01-31 00:00:00 22.00 0.35000 0.76500 179500324860 Anemometer m/s 4 50.00 5 NRG 40C Anem 2020-01-31 00:00:00 12.00 0.35000 0.76500 179500324859 Anemometer m/s 5 230.00 6 NRG S1 2020-01-31 00:00:00 12.00 0.13900 0.09350 94120000056 Anemometer m/s 6 320.00 13 NRG 200M Vane 2020-01-31 00:00:00 32.00 -1.46020 147.91100 10700000125 Vane Deg 7 320.00 14 NRG 200M Vane 2020-01-31 00:00:00 21.00 -1.46020 147.91100 10700000124 Vane Deg 8 0.00 15 NRG T60 Temp 2020-01-31 00:00:00 34.00 -40.85550 44.74360 9400000705 Analog C 9 0.00 16 NRG T60 Temp 2020-01-31 00:00:00 2.00 -40.85550 44.74360 9400000xxx Analog C 10 0.00 17 NRG RH5X Humi 2020-01-31 00:00:00 0.00 0.00000 20.00000 NaN Analog %RH 11 0.00 20 NRG BP60 Baro 2020-01-31 00:00:00 0.00 495.27700 243.91400 NaN Analog hPa 12 0.00 21 NRG BP60 Baro 2020-01-31 00:00:00 2.00 495.04400 244.23900 9396FT1937 Analog hPa
-
format_data_for_epe
()¶
-
format_site_data
()¶ take txt header to create oject data
-
insert_blank_header_rows
(filename)¶ insert blank rows when using shift_timestamps()
ensures the resulting text file looks and feels like an original Sympro Desktop exported
-
make_header_for_epe
()¶
-
output_txt_file
(epe=False, soiling=False, standard=True, shift_timestamps=False, out_file='', **kwargs)¶
-
select_channels_for_reformat
(epe=False, soiling=False)¶ determines which of the channel headers fit those required for post-processing for either
EPE formatting
soiling ratio calculation
Note that this formatting requires the the channel headers to be full (requires Local export of text files, as of 0.1.8.
-
nrgpy.txt_utils module¶
-
nrgpy.txt_utils.
format_sympro_site_data
(reader)¶ adds formatted site dataframe to reader object
-
class
nrgpy.txt_utils.
read_text_data
(filename='', data_type='sp3', txt_dir='', file_filter='', filter2='', file_ext='', sep='\t')¶ Bases:
object
class for handling known csv-style text data files with header information
- Parameters
filename (str, optional) – perform a single file read (takes precedence over txt_dir)
data_type (str) – specify instrument that the data file came from
sep (str) – ‘ ‘; csv separator
txt_dir (str) – folder path of text files to read and concatenate
file_filter (str, optional) – use when using txt_dir to filter on subset of files
file_ext (str, optional) – secondary file filter
-
arrange_ch_info
()¶ generates list and dataframe of channel information
-
concat
(output_txt=False, out_file='', file_filter='', filter2='', progress_bar=True)¶ combine exported rwd files (in txt format)
- Parameters
output_txt (bool) – set to True to save a concatenated text file
out_file (str) – filepath, absolute or relative
file_filter (str) –
filter2 (str) –
progress_bar (bool) –
-
format_rwd_site_data
()¶ adds formatted site dataframe to reader object
-
get_data
(_file)¶ create dataframe of tabulated data
-
get_head
(_file)¶ get the first lines of the file
excluding those without tabs up to the self.skip_rows line
-
get_site_info
(_file)¶ create dataframe of site info
nrgpy.utilities module¶
-
nrgpy.utilities.
affirm_directory
(directory)¶ create directory if not exists
print status to terminal
-
nrgpy.utilities.
check_platform
()¶ determine which operating system python is running on
-
nrgpy.utilities.
count_files
(directory, filters, extension, show_files=False, **kwargs)¶ counts the number of files in the first level of a directory
- Parameters
directory (str) – path of directory to be checked
filters (str) – filter present in file to be checked
extension (str) – secondary filter
show_files (bool, optional) – if set to True, prints file name
start_time (int) – seconds; if set, use as reference; only count if file is newer than start_time
-
nrgpy.utilities.
date_check
(start_date, end_date, string)¶ returns true if string date is between dates
- Parameters
start_date (str) – “YYYY-mm-dd”
end_date (str) – “YYYY-mm-dd”
string (str) – string including date to check
-
nrgpy.utilities.
draw_progress_bar
(index, total, start_time, barLen=45)¶ simple text progress bar
-
nrgpy.utilities.
linux_folder_path
(folder_path)¶ assert folder_path ending with ‘/’
-
class
nrgpy.utilities.
renamer
¶ Bases:
object
for replacing duplicate column names after transpose
-
nrgpy.utilities.
windows_folder_path
(folder_path)¶ convert ‘/’ to ‘' in folder_path and assert ending in ‘'