def create_filereports(file_data_dicts, event, destination, current_trial, trial_doc_folder, default_folder): """Creates reports without interfacing with the files themselves.""" for file_ in file_data_dicts: pubChan = "%s_%s_%s" % (file_[cfg_fl_net], file_[cfg_fl_sta], file_[cfg_fl_chan]) channel_data_dict = smysql.retrieve_channel_position(pubChan, event[cfg_evt_time]) report.append_report_if_valid(trial_doc_folder, file_, channel_data_dict, event[cfg_evt_evid])
def generate_evid_report(filepath, event_id, exp_num, evt_type="Earthquake", filename="report.csv"): """Creates report based on mySQL database in the requested folder. Args: filepath: Folder path where you want a report.csv created. event_id: Event ID of the requested event. exp_num: Experiment Number of the event """ site_list = mySQL_sitedef[exp_num] station_list = mySQL_stadef[exp_num] event_dicts = smysql.retrieve_event_description(list_of_sites=site_list, evid=event_id) event_dict = utils.dict_frm_singular_list(event_dicts) site_evt = event_dict[cfg_evt_siteEvt] create_report(filepath, event_dict, evt_type, filename) # Parse through all files to create individual folder lines. file_list = smysql.retrieve_file_location(site_evt, station_list) for file_dict in file_list: event_time = event_dict[cfg_evt_time] pub_chan = "%s_%s_%s" % (file_dict[cfg_fl_net], file_dict[cfg_fl_sta], file_dict[cfg_fl_chan]) channel_dict = smysql.retrieve_channel_position(pub_chan, event_time) append_report_if_valid(filepath, file_dict, channel_dict, filename)
def generate_CSV(filepath, siteEvt, channel_list="all", time="", evt_type="Earthquake"): """Generates CSV file with custom number of channels. Args: filepath: Folder path or filename path. If filepath is entered as folder path report.csv will be used. siteEvt: MYSQL database specific siteEVT assigned to the lookup. Enter 0 if you want to create report for non-event type database. Channel_List: List of channels you wish to display. Can either be a Python List or a string list with comma separated values. Leaving blank or "all" uses all channels. time: Time of non-event trials, such as SFSI. If siteEvt is specified, this is ignored. evt_type: Header event type for report.csv file. Defaulted at "Earthquake" """ file_parse = utils.parse_file_path(filepath) filename = file_parse["filename"] folder_path = file_parse["folder"] channel_cond = utils.parse_channel_list(channel_list) # If this is a standard event type, proceed normally. if siteEvt != 0: event_dicts = smysql.retrieve_event_description(site_evt=siteEvt) event_dict = utils.dict_frm_singular_list(event_dicts) create_report(folder_path, event_dict, evt_type, filename) file_list = smysql.retrieve_file_location(siteEvt) # Look through every file associated with this siteEvt. for file_dict in file_list: event_time = event_dict[cfg_evt_time] pub_chan = "%s_%s_%s" % (file_dict[cfg_fl_net], file_dict[cfg_fl_sta], file_dict[cfg_fl_chan]) # Check if we are allowed to use this channel for creation. if pub_chan in channel_cond or channel_cond == "all": channel_dict = smysql.retrieve_channel_position(pub_chan, event_time) append_report_if_valid(folder_path, file_dict, channel_dict, filename) # None Event report creation begins if the proper key is set. elif siteEvt == 0: print "VAL YOU NEED TO PROGRAM IN A REPORT CREATION FOR CROSS-HOLES AND SFSI SHAKES"