nrgpy.utils package#
Submodules#
nrgpy.utils.encodings module#
- class nrgpy.utils.encodings.convert_utf16le_to_utf8(filename='', input_directory='', output_directory='', inplace=False)[source]#
Bases:
object
for making Spidar data files compatible with programs that do not support utf-16-le character encoding
- Parameters:
- filenamestr
(optional) path of file to convert
- input_directorystr
(optional) path of directory with files to convert
- output_directorystr
(optional) path of directory store converted files in
- inplacebool
(False) if true, overwrites filename provided
- Returns:
- None
Examples
convert single file
>>> import nrgpy >>> filename = "/path/to/files/file.zip" >>> nrgpy.convert_utf16le_to_utf8(filename)
convert directory of files
>>> input_directory = "/path/to/files/" >>> nrgpy.convert_utf16le_to_utf8(input_directory=input_directory)
nrgpy.utils.ipk2lgr module#
nrgpy.utils.nsd_functions module#
- class nrgpy.utils.nsd_functions.nsd(nsd_file='')[source]#
Bases:
object
class for handling NSD files from Symphonie Logger Data.
- Parameters:
- nsd_filestr
path to nsd file to open for reading and writing
- Returns:
- obj
- 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)[source]#
use for adding new sensor history registries
- Parameters:
- timestampstring
“YYYY-MM-DD HH:MM:SS”
- channelint
or string, channel number
- sensor_typeint
- or string, number:
1 : anemometer 2 : totalizer (rain gauge) 3 : vane 4 : analog (temp, bp, rh, etc.)
- sensor_descstring
description
- print_precisionint
1 through 4, number of decimals
- unitsstring
- serial_numberstring
- heightfloat
- sensor_detailnote
- sensor_notesnote
- scale_factorfloat
- offsetfloat
- check_for_jet_drivers()[source]#
check for jet database drivers
- Returns:
- bool
True if drivers present, otherwise False
- check_platform() linux #
determine which operating system python is running on
- read_channel_settings(channel=0, dash=False)[source]#
read individual channel settings from sensor history table
- Parameters:
- channelint
1 through 15 (12 if Sym Classic nsd file)
- Returns:
- obj
pandas dataframe of channel details
- read_sensor_history()[source]#
read SensorHistory table into dataframe
- Returns:
- obj
sensor_history : pandas dataframe
- 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)[source]#
write new sensor history to site file
- Parameters:
- channelint
required; 1 through 15 (or 1 through 12 for Sym Classic)
- entryint
default is 1 for channel baseline values, 2, 3, etc. for newer entries
- sensor_descstring
- print_precisionint
1, 2, 3, or 4 or 0 for off
- unitsstring
- serial_numberstring
- heightstring
- sensor_detailstring
- sensor_notesstring
- scale_factorfloat
- offsetfloat
nrgpy.utils.utilities module#
- nrgpy.utils.utilities.affirm_directory(directory: str) None [source]#
create directory if not exists
print status to terminal
- nrgpy.utils.utilities.check_platform() linux [source]#
determine which operating system python is running on
- nrgpy.utils.utilities.count_files(directory: str, filters: str, extension: str, show_files: bool = False, **kwargs) int [source]#
counts the number of files in the first level of a directory
- Parameters:
- directorystr
path of directory to be checked
- filtersstr
filter present in file to be checked
- extensionstr
secondary filter
- show_filesbool, optional
if set to True, prints file name
- start_timeint
seconds; if set, use as reference; only count if file is newer than start_time
- nrgpy.utils.utilities.data_months(start_date: str, end_date: str, output: str = 'string') list [source]#
returns list of months for a date range in YYYY-mm-dd format
- Parameters:
- start_datestr or datetime
YYYY-mm-dd formatted date or datetime object
- end_datestr or datetime
must be same formatting as start_date or god help you
- outputstr
“string” or “datetime”; specify date types you want returned.
- Returns:
- list
- nrgpy.utils.utilities.date_check(start_date: str, end_date: str, string: str) bool #
returns true if string date is between dates
- Parameters:
- start_datestr
“YYYY-mm-dd”
- end_datestr
“YYYY-mm-dd”
- stringstr
string including date to check
- nrgpy.utils.utilities.draw_progress_bar(index, total, start_time, barLen=45, header='Time elapsed', label='') None [source]#
simple text progress bar
- nrgpy.utils.utilities.fix_export_siteid_filename(filepath: str, site_number: str) str [source]#
Change out NRG Cloud site id with padded site number
- nrgpy.utils.utilities.is_sympro_running() bool [source]#
checks pid list for instance of sympro running
- nrgpy.utils.utilities.linux_folder_path(folder_path) str [source]#
assert folder_path ending with ‘/’
- nrgpy.utils.utilities.load(site_number: str = '', serial_number: str = '', filename: str = '') object [source]#
recall a reader from a pickle file by site number or filename
- Parameters:
- site_numberstr
6-digit site number of stored reader OR spidar serial number
- filenamestr
full or relative path of pickle file
- Returns:
- object
contents of pickle file
- nrgpy.utils.utilities.rename_cloud_export_like_spd(filepath: str) bool [source]#
rename nrg cloud export files with SPD formatting
- class nrgpy.utils.utilities.renamer[source]#
Bases:
object
for replacing duplicate column names after transpose
- nrgpy.utils.utilities.save(reader, filename='') None [source]#
save reader as a Python pickle file, to be recalled later