Skip to content

Allow single temp/cond sensor setup #38

@oyvfoss

Description

@oyvfoss

I am getting an error trying to read CTD data when there was only one single temperature sensor. Would be good to allow single-sensor setups as they are common outside of large research vessels (and even on large vessels, things can happen to the sensors..). As long as single-sensor setups don't affect the hex-file structure, it shouldn't be too hard to implement here, I suppose?

I haven't investigated in detail, but it looks like this particular error occured due to missing secondary temperature and in io.physicalunits. I think the same applies to conductivity, though, and it looks like there might also be functions in calcs and proc that assume secondary temp/cond.

Not sure what the best way to handle this is. Two conceivable general approaches, I guess:

  1. Let a function like _freq2temp take N/A and return N/A, resulting in N/A values for e.g. temp2.
    • Could consider removing such empty fields at the end of the read.
  2. Avoid generating these variables at all if no secondary data is found.

import ctdproc
d = ctdproc.io.CTDHex(hexfile)

Gives:

AttributeError: 'DataFrame' object has no attribute 'TemperatureSensor2'
Detailed output

AttributeError Traceback (most recent call last)
/tmp/ipykernel_16281/3247887479.py in ?()
----> 1 d = ctdproc.io.CTDHex(hexfile)

~/work/code/python/ctdproc/ctdproc/io.py in ?(self, filename)
78 p="dbar",
79 )
80
81 # extract all data and metadata and convert to physical units
---> 82 self._extract_physical_data()

~/work/code/python/ctdproc/ctdproc/io.py in ?(self)
84 def _extract_physical_data(self):
85 self.read_xml_config()
86 self.parse_hex()
---> 87 self.physicalunits()

~/work/code/python/ctdproc/ctdproc/io.py in ?(self)
501 self.data.t1 = self._freq2temp(
502 self.dataraw.t1, self.cfgp.TemperatureSensor1.cal
503 )
504 self.data.t2 = self._freq2temp(
--> 505 self.dataraw.t2, self.cfgp.TemperatureSensor2.cal
506 )
507 ccal1 = self.cfgp.ConductivitySensor1.cal.Coefficients[1]
508 self.data.c1 = self._freq2cond(

~/mambaforge/envs/ctdproc/lib/python3.8/site-packages/pandas/core/generic.py in ?(self, name)
5985 and name not in self._accessors
5986 and self._info_axis._can_hold_identifiers_and_holds_name(name)
5987 ):
5988 return self[name]
-> 5989 return object.getattribute(self, name)

AttributeError: 'DataFrame' object has no attribute 'TemperatureSensor2'

<\details>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions