Commit e3bfa471 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Stored values in float, fix rstrip bug

parent 2a8d365c
......@@ -40,7 +40,7 @@ def make_sigmf(metadatafilename, no_rename=False):
rx_gain = float(rx_gain)
time_first_sample = Time(float(time_first_sample), format="unix")
sigmfname_meta = metadatafilename.rstrip(".metadata").rstrip("sigmf-data") + "sigmf-meta"
sigmfname_meta = metadatafilename.replace(".metadata", "").replace(".sigmf-data", ".sigmf-meta")
meta = {}
meta["global"] = {}
......@@ -51,7 +51,7 @@ def make_sigmf(metadatafilename, no_rename=False):
"core:license"] = "https://creativecommons.org/licenses/by/4.0/"
global_meta["core:author"] = "Stichting CAMRAS"
global_meta["core:recorder"] = "usrp_to_file"
global_meta["core:dataset"] = metadatafilename.rstrip(".metadata")
global_meta["core:dataset"] = metadatafilename.replace(".metadata", "")
global_meta["core:datatype"] = dataformat_to_str(dataformat)
global_meta["core:sample_rate"] = rate
global_meta["core:hw"] = sdr_type.strip('"')
......@@ -86,17 +86,17 @@ def make_sigmf(metadatafilename, no_rename=False):
global_meta["camras:pointing:tracking"] = pointingdata[
'setpoint'].strip('"')
global_meta[
"camras:pointing:az_deg"] = f"{(pointingdata['az'] + 180) % 360:.4f}"
global_meta["camras:pointing:el_deg"] = f"{pointingdata['el']:.4f}"
"camras:pointing:az_deg"] = round((pointingdata['az'] + 180) % 360, 4)
global_meta["camras:pointing:el_deg"] = round(pointingdata['el'], 4)
if pointingdata['offset'].strip() == "":
offset_az_deg = 0
offset_el_deg = 0
else:
offset_az_str, offset_el_str = pointingdata['offset'].split(',')
offset_az_str = offset_az_str.strip().rstrip('°')
offset_el_str = offset_el_str.strip().rstrip('°')
global_meta["camras:pointing:offset:az_deg"] = offset_az_str
global_meta["camras:pointing:offset:el_deg"] = offset_el_str
offset_az_str = offset_az_str.strip().replace('°', '')
offset_el_str = offset_el_str.strip().replace('°', '')
global_meta["camras:pointing:offset:az_deg"] = float(offset_az_str)
global_meta["camras:pointing:offset:el_deg"] = float(offset_el_str)
global_meta["camras:pointing:datetime"] = Time.now(
).iso[:19] # Pointing is only accurate to the second
else:
......@@ -104,21 +104,21 @@ def make_sigmf(metadatafilename, no_rename=False):
tracker = dt.tracker.replace("console/", "")
global_meta["camras:pointing:tracking"] = dt.tracker
global_meta[
"camras:pointing:az_deg"] = f"{(dt.az.value + 180) % 360:.4f}"
global_meta["camras:pointing:el_deg"] = f"{dt.el.value:.4f}"
"camras:pointing:az_deg"] = round((dt.az.value + 180) % 360, 4)
global_meta["camras:pointing:el_deg"] = round(dt.el.value, 4)
global_meta[
"camras:pointing:offset:az_deg"] = f"{dt.offset_az.value:+.4f}"
"camras:pointing:offset:az_deg"] = round(dt.offset_az.value, 4)
global_meta[
"camras:pointing:offset:el_deg"] = f"{dt.offset_el.value:+.4f}"
global_meta["camras:focusbox_position_m"] = f"{dt.focusbox_pos:.3f}"
"camras:pointing:offset:el_deg"] = round(dt.offset_el.value, 4)
global_meta["camras:focusbox_position_m"] = round(dt.focusbox_pos, 3)
global_meta["camras:pointing:datetime"] = Time.now(
).datetime.isoformat()
if tracker == 'j2000tracker':
sky = dt.getRaDec()
global_meta["camras:pointing:ra_deg"] = f"{dt.radec.ra.deg:.4f}"
global_meta["camras:pointing:dec_deg"] = f"{dt.radec.dec.deg:.4f}"
global_meta["camras:pointing:ra_deg"] = round(dt.radec.ra.deg, 4)
global_meta["camras:pointing:dec_deg"] = round(dt.radec.dec.deg, 4)
global_meta["camras:pointing:radec_hmsdms"] = sky.to_string('hmsdms')
objects = Table.read('camras_objects.ecsv')
......@@ -130,7 +130,7 @@ def make_sigmf(metadatafilename, no_rename=False):
global_meta["camras:pointing:nearest_object"] = names[
idx].strip('"')
global_meta[
"camras:pointing:nearest_object_separation_deg"] = f"{separation.deg:.4f}"
"camras:pointing:nearest_object_separation_deg"] = round(separation.deg, 4)
elif tracker == 'sattracker':
global_meta["camras:pointing:satname"] = dt.satname
global_meta["camras:pointing:tle1"] = dt.tle1
......@@ -143,12 +143,12 @@ def make_sigmf(metadatafilename, no_rename=False):
global_meta[
"camras:pointing:refraction_enabled"] = f"{dt.refraction_enabled}"
global_meta["camras:rx_gain"] = rx_gain
global_meta["camras:bandwidth"] = bandwidth
global_meta["camras:reference"] = reference.strip('"')
global_meta["camras:time_source"] = time_source.strip('"')
global_meta["camras:antenna"] = antenna.strip('"')
global_meta["camras:channel"] = channel
global_meta["camras:usrp:rx_gain"] = rx_gain
global_meta["camras:usrp:bandwidth"] = bandwidth
global_meta["camras:usrp:reference"] = reference.strip('"')
global_meta["camras:usrp:time_source"] = time_source.strip('"')
global_meta["camras:usrp:antenna"] = antenna.strip('"')
global_meta["camras:usrp:channel"] = channel
with open(sigmfname_meta, "w") as sigmfmeta:
json.dump(meta, sigmfmeta, indent=4)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment