mth5.io.zen.zen_tools

Created on Tue Apr 18 15:40:28 2023

@author: jpeacock

Classes

ZenSchedule

deals with reading, writing and copying schedule

Functions

get_drives()

get a list of logical drives detected on the machine

get_drive_names()

get a list of drive names detected assuming the cards are names by box

split_station(station)

split station name into name and number

copy_from_sd(station[, save_path, channel_dict, ...])

copy files from sd cards into a common folder (save_path)

delete_files_from_sd([delete_date, delete_type, ...])

delete files from sd card, if delete_date is not None, anything on this

Module Contents

mth5.io.zen.zen_tools.get_drives()[source]

get a list of logical drives detected on the machine Note this only works for windows. Outputs: ———-

drives : list of drives as letters

Example:

:: >>> import mtpy.usgs.zen as zen >>> zen.get_drives()

mth5.io.zen.zen_tools.get_drive_names()[source]

get a list of drive names detected assuming the cards are names by box and channel. Outputs: ———-

drive_dictdictionary

keys are the drive letters and values are the drive names

Example:

:: >>> import mtpy.usgs.zen as zen >>> zen.get_drives_names()

mth5.io.zen.zen_tools.split_station(station)[source]

split station name into name and number

mth5.io.zen.zen_tools.copy_from_sd(station, save_path='d:\\Peacock\\MTData', channel_dict={'1': 'HX', '2': 'HY', '3': 'HZ', '4': 'EX', '5': 'EY', '6': 'HZ'}, copy_date=None, copy_type='all')[source]

copy files from sd cards into a common folder (save_path) do not put an underscore in station, causes problems at the moment Arguments: ———–

stationstring

full name of station from which data is being saved

save_pathstring

full path to save data to

channel_dictdictionary

keys are the channel numbers as strings and the values are the component that corresponds to that channel, values are placed in upper case in the code

copy_dateYYYY-MM-DD

date to copy from depending on copy_type

copy_type[ ‘all’ | ‘before’ | ‘after’ | ‘on’ ]
  • ‘all’ –> copy all files on the SD card

  • ‘before’ –> copy files before and on this date

  • ‘after’ –> copy files on and after this date

  • ‘on’ –> copy files on this date only

Outputs:

fn_listlist

list of filenames copied to save_path

Example:

:: >>> import mtpy.usgs.zen as zen >>> fn_list = zen.copy_from_sd(‘mt01’, save_path=r”/home/mt/survey_1”)

mth5.io.zen.zen_tools.delete_files_from_sd(delete_date=None, delete_type=None, delete_folder='d:\\Peacock\\MTData\\Deleted', verbose=True)[source]

delete files from sd card, if delete_date is not None, anything on this date and before will be deleted. Deletes just .Z3D files, leaves zenini.cfg Agruments: ———–

delete_dateYYYY-MM-DD

date to delete files from

delete_type[ ‘all’ | ‘before’ | ‘after’ | ‘on’ ]
  • ‘all’ –> delete all files on sd card

  • ‘before’ –> delete files on and before delete_date

  • ‘after’ –> delete files on and after delete_date

  • ‘on’ –> delete files on delete_date

delete_folderstring

full path to a folder where files will be moved to just in case. If None, files will be deleted for ever.

Returns:

delete_fn_listlist

list of deleted files.

Example:

:: >>> import mtpy.usgs.zen as zen >>> # Delete all files before given date, forever. >>> zen.delete_files_from_sd(delete_date=’2004/04/20’,

delete_type=’before’, delete_folder=None)

>>> # Delete all files into a folder just in case
>>> zen.delete_files_from_sd(delete_type='all',
                             delete_folder=r"/home/mt/deleted_files")
class mth5.io.zen.zen_tools.ZenSchedule[source]

Bases: object

deals with reading, writing and copying schedule Creates a repeating schedule based on the master_schedule. It will then change the first scheduling action to coincide with the master schedule, such that all deployed boxes will have the same schedule. :Example:

>>> import mtpy.usgs.zen as zen
>>> zs = zen.ZenSchedule()
>>> zs.write_schedule('MT01', dt_offset='2013-06-23,04:00:00')

Attributes

Description

ch_cmp_dict

dictionary for channel components with keys being the channel number and values being the channel label

ch_num_dict

dictionary for channel components whith keys being channel label and values being channel number

df_list

sequential list of sampling rates to repeat in

schedule

df_time_list

sequential list of time intervals to measure for

each corresponding sampling rate

dt_format

date and time format. default is YYY-MM-DD,hh:mm:ss

dt_offset

start date and time of schedule in dt_format

gain_dict

dictionary of gain values for channel number

initial_dt

initial date, or dummy zero date for scheduling

light_dict

dictionary of light color values for schedule

master_schedule

the schedule that all data loggers should schedule at. Will taylor the schedule to match the master schedule according to dt_offset

meta_dict

dictionary for meta data

meta_keys

keys for meta data dictionary

sa_keys

keys for schedule actions

sa_list

list of schedule actions including time and df

sr_dict

dictionary of sampling rate values

verbose

[ True | False ] True to print information to console

verbose = True[source]
sr_dict[source]
sa_list = [][source]
ch_cmp_dict[source]
ch_num_dict[source]
dt_format = '%Y-%m-%d,%H:%M:%S'[source]
initial_dt = '2000-01-01,00:00:00'[source]
dt_offset[source]
df_list = (4096, 256)[source]
df_time_list = ('00:10:00', '07:50:00')[source]
master_schedule[source]
add_time(date_time, add_minutes=0, add_seconds=0, add_hours=0, add_days=0)[source]

add time to a time string assuming date_time is in the format YYYY-MM-DD,HH:MM:SS

make_schedule(df_list, df_length_list, repeat=5, t1_dict=None)[source]

make a repeated schedule given list of sampling frequencies and duration for each. Arguments: ———–

df_listlist

list of sampling frequencies in Hz, note needs to be powers of 2 starting at 256

df_length_listlist

list of durations in hh:mm:ss format

repeatint

number of times to repeat the sequence

t1_dictdictionary

dictionary returned from get_schedule_offset

Returns:

time_list: list of dictionaries with keys:
  • ‘dt’ –> date and time of schedule event

  • ‘df’ –> sampling rate for that event

get_schedule_offset(time_offset, schedule_time_list)[source]

gets the offset in time from master schedule list and time_offset so that all schedules will record at the same time according to master schedule list schedule_time_list Attributes: ———–

time_offsethh:mm:ss

the time offset given to the zen reciever

schedule_time_listlist

list of actual schedule times returned from make_schedule

Returns:

s1dictionary
dictionary with keys:
  • ‘dt’ –> date and time of offset from next schedule

    event from schedule_time_list

  • ‘df’ –> sampling rate of that event

write_schedule_for_gui(zen_start=None, df_list=None, df_time_list=None, repeat=8, gain=0, save_path=None, schedule_fn='zen_schedule.MTsch', version=4)[source]

write a zen schedule file Note: for the older boxes use ‘Zeus3Ini.cfg’ for the savename Arguments: ———-

zen_starthh:mm:ss

start time you want the zen to start collecting data. if this is none then current time on computer is used. In UTC Time Note: this will shift the starting point to

match the master schedule, so that all stations have the same schedule.

df_listlist

list of sampling rates in Hz

df_time_listlist

list of time intervals corresponding to df_list in hh:mm:ss format

repeatint

number of time to repeat the cycle of df_list

gainint

gain on instrument, 2 raised to this number.

Returns:

  • writes a schedule file to input into the ZenAcq Gui