vtsuperdarn / davitpy

DEPRECATED The DaViT Python project
http://vtsuperdarn.github.com/davitpy/
GNU General Public License v3.0
37 stars 59 forks source link

Feature request: Pattern based scan contruction #182

Closed asreimer closed 8 years ago

asreimer commented 8 years ago

Sometimes SuperDARN radars are run in a patterned type scan mode as can be seen with the Hankasalmi radar on datetime(2013, 11, 3, 19, 0) (cpid:153, see https://github.com/vtsuperdarn/davitpy/issues/181).

Since it is still desireable to be able to plot FOV plots of these radar modes, perhaps one could make a readScanPattern() function that would take a pattern and return a scanData object for it. For example, if the pattern of beam numbers was: 15, 9, 14, 9, 13, 9, 12, 9, 11, 9, 10, 9, 9, 9, 8, 9, ... then with the appropriate arguments, readScanPattern() would return a scan consisting of beams: 15, 14, 13, 12, 11, 10, 9, ...

aburrell commented 8 years ago

That would be nice. One thing I’ve been doing to get around this is to run update_backscatter for a particular cpid, which usually separates the patterned scans from the normal scans. However, it would be beneficial to have the scan function be smart enough to distinguish this on its own.

On 12 Nov 2015, at 19:14, Ashton Reimer notifications@github.com wrote:

Sometimes SuperDARN radars are run in a patterned type scan mode as can be seen with the Hankasalmi radar on datetime(2013, 11, 3, 19, 0) (cpid:153, see #181 https://github.com/vtsuperdarn/davitpy/issues/181).

Since it is still desireable to be able to plot FOV plots of these radar modes, perhaps one could make a readScanPattern() function that would take a pattern and return a scanData object for it. For example, if the pattern of beam numbers was: 15, 9, 14, 9, 13, 9, 12, 9, 11, 9, 10, 9, 9, 9, 8, 9, ... then with the appropriate arguments, readScanPattern() would return a scan consisting of beams: 15, 14, 13, 12, 11, 10, 9, ...

— Reply to this email directly or view it on GitHub https://github.com/vtsuperdarn/davitpy/issues/182.

cmeeren commented 8 years ago

@aburrell, what's update_backscatter? I can't find it in the code.

cmeeren commented 8 years ago

I don't have time to make a proper function, but here is an ugly hack of radDataPtr.readScan() which takes every other beam starting with he first beam in the scan. I also included the abs() suggestion from #183 because I need it. The only new stuff apart from abs are the lines using i. Works for both pyk and han for datetime(2013, 11, 3, 19, 0). Might be useful if this scan pattern is encountered a lot.

  def readScanPattern(self):
    """A function to read a full scan of data from a :class:`pydarn.sdio.radDataTypes.radDataPtr` object

    This reads patterned scans by starting at the first beam in a scan and only including
    every other beam.

    """
    from davitpy.pydarn.sdio import scanData
    from davitpy import pydarn
    #Save the radDataPtr's bmnum setting temporarily and set it to None
    orig_beam=self.bmnum
    self.bmnum=None

    if self.__ptr is None:
        print 'Error, self.__ptr is None.  There is probably no data available for your selected time.'
        return None

    if self.__ptr.closed:
        print 'error, your file pointer is closed'
        return None

    myScan = scanData()
    i = 0
    while(1):
        i += 1
        myBeam=self.readRec()
        if myBeam is None:
            break

        if i % 2 == 0:
            offset = pydarn.dmapio.getDmapOffset(self.__fd)
            continue

        if ((abs(myBeam.prm.scan) == 1 and len(myScan) == 0)         # Append a beam if it is the first in a scan AND nothing has been added to the myScan object.
         or (myBeam.prm.scan == 0 and  len(myScan) > 0) ):      # Append a beam if it is not the first in a scan AND the myScan object has items.
            myScan.append(myBeam)
            offset = pydarn.dmapio.getDmapOffset(self.__fd)
        elif abs(myBeam.prm.scan) == 1 and len(myScan) > 0:          # Break out of the loop if we are on to the next scan and rewind the pointer to the previous beam.
            s = pydarn.dmapio.setDmapOffset(self.__fd,offset)
            break

    if len(myScan) == 0: myScan = None
    self.bmnum=orig_beam
    return myScan
asreimer commented 8 years ago

Patterned scanned parsing has been implemented by #189