Example #1
0
def append_report(filepath, sensor_data_dict, channel_data_dict, filename="report.csv"):
    """This function will be run once for every file that is moved over from the data directory into the local NEEShub directory.
    Does not delete existing report.csv. Only appends it."""
    sdd = sensor_data_dict
    cdd = channel_data_dict
    filepath = utils.close_folder_path(filepath)
    with open(filepath + filename, "a") as report:
        sensor_type = sdd[cfg_fl_segtype]
        calib = sdd[cfg_fl_calib]
        sta_chan_loc = sdd[cfg_fl_dfile]
        depth = cdd[cfg_chan_dpth]
        n_off = cdd[cfg_chan_noffset]
        e_off = cdd[cfg_chan_eoffset]
        cal_units = mySQL_calibdef[sensor_type]

        report.write("%s,%s,%s,%s,%s,%s,%s\n" % (sta_chan_loc, sensor_type, calib, cal_units, depth, n_off, e_off))
Example #2
0
def create_report(filepath, event_data_dict, evt_type="Earthquake", filename="report.csv"):
    """This function starts the report making process. Populates the general event information, giving Event Id,
    time of event, magnitude, distance and depth, or the dictionary that the ucsbsql_interface module that creates.
    WARNING: This will delete existing report.csv files located in the filepath."""
    mdd = event_data_dict
    filepath = utils.close_folder_path(filepath)
    with open(filepath + filename, "w") as report:
        time_now = str(datetime.datetime.utcnow())
        epoch_time = mdd[cfg_evt_time]
        event_time = str(datetime.datetime.fromtimestamp(epoch_time).strftime(default_time_format))
        event_ml = str(float(mdd[cfg_evt_ml]) / 100.00)
        event_id = str(mdd[cfg_evt_evid])
        event_distance = str(mdd[cfg_evt_dist])
        event_depth = str(mdd[cfg_evt_depth])

        report.write("NEES@UCSB Data Request on " + time_now + "\n\n")
        report.write("NOTE: miniseed files are never calibrated\n\n")
        report.write("%s::,\n" % (evt_type,))
        report.write("Evid:,Time:,Mag:,Dist.(m):,Depth(m):\n")
        report.write("%s,%s,%s,%s,%s\n\n" % (event_id, event_time, event_ml, event_distance, event_depth))
        report.write(
            "CALIBRATION IN PHYSICAL UNITS PER COUNT. Multiply counts by calibration value to get physical measurement.\n\n"
        )
        report.write("STA_CHAN_LOC, Sensor Type, Calib, Cal Units, Depth(m),N_off(m), E_off(m)\n")