def test_01(self):
        """CurveCfgXMLRead.test_01(): tests single channel read."""
        # Say in <LgTrack UniqueId="track1">
        xStr = """<LgCurve UniqueId="Cali" xmlns="x-schema:LgSchema2.xml">
    <ChannelName>CALI</ChannelName>
    <Color>FF0000</Color>
    <LeftLimit>6</LeftLimit>
    <LineStyle>LG_DASH_LINE</LineStyle>
    <RightLimit>16</RightLimit>
    <Thickness>2</Thickness>
    <WrapCount>1</WrapCount>
</LgCurve>"""
        root = etree.fromstring(xStr)
        myCcxr = PRESCfgXML.CurveCfgXMLRead(root, "track1", self._fcxr)
        #        print()
        #        print('myCcxr._filmTrackWidthMap [{:d}]'.format(len(myCcxr._filmTrackWidthMap)))
        #        pprint.pprint(myCcxr._filmTrackWidthMap)
        #        print()
        #        print('myCcxr._filmTrackFnMap [{:d}]'.format(len(myCcxr._filmTrackFnMap)))
        #        pprint.pprint(myCcxr._filmTrackFnMap)
        self.assertEqual('Cali', myCcxr.mnem)
        self.assertEqual('CALI', myCcxr.outp)
        self.assertEqual(True, myCcxr.stat)
        self.assertEqual('track1', myCcxr.trac)
        self.assertEqual(
            Stroke.Stroke(width=0.5,
                          colour='rgb(255,0,0)',
                          coding=(4, 4),
                          opacity=1.0),
            myCcxr.codiStroke,
        )
 def test_03(self):
     """PresCfgXMLRead.test_03(): create a PRESCfgXML.PresCfgXMLRead() from "Resistivity_3Track_Logrithmic.xml" correct curves."""
     myPcxr = PRESCfgXML.PresCfgXMLRead(
         self._fcxr,
         "Resistivity_3Track_Logrithmic.xml",
     )
     self.assertEqual(
         sorted([
             Mnem.Mnem(v, len_mnem=0) for v in [
                 'PCAL',
                 'ILD',
                 'AHT60_8',
                 'MSFL',
                 'ILM',
                 'AHO90_9',
                 'ATR',
                 'AHF90_9',
                 'AHF30_7',
                 'A34H_ARC',
                 'AHT10_6',
                 'AHF60_8',
                 'RXO',
                 'AHT90_9',
                 'LLM',
                 'RLA1',
                 'AHT30_7',
                 'RLA3',
                 'RLA2',
                 'RLA5',
                 'RLA4',
                 'P34H_ARC',
                 'LLD',
                 'ROP5',
                 'A22H_ARC',
                 'AHO60_8',
                 'AHF20_5',
                 'BS_7',
                 'RLA0',
                 'AHO30_7',
                 'AHT20_5',
                 'P28H_ARC',
                 'SP_10',
                 'GR_9',
                 'AHO10_6',
                 'HiltCaliper',
                 'AHF10_6',
                 'TENS_6',
                 'SFL',
                 'P16H_ARC',
                 'AHO20_5',
                 'PSR',
                 'CALI_8',
             ]
         ]),
         sorted(myPcxr.keys()),
     )
     self.assertTrue('BS_7' in myPcxr)
 def test_02(self):
     """PresCfgXMLRead.test_02(): create a PRESCfgXML.PresCfgXMLRead() from "Resistivity_3Track_Logrithmic.xml" number of curves."""
     myPcxr = PRESCfgXML.PresCfgXMLRead(
         self._fcxr,
         "Resistivity_3Track_Logrithmic.xml",
     )
     #        print('')
     #        pprint.pprint(self._fcxr._chOutpMnemFilmMap)
     #        print(myPcxr.keys())
     self.assertEqual(43, len(myPcxr))
Exemple #4
0
 def _plotUsingLgFormats(self, theFi, theLpIdx, thePrs, theFpOut):
     """Plots a LogPass from a LIS file using the LgFormat XML files
     specify the plot.
     theFi - the LIS File object.
     theLpIdx - integer for the LogPass in the LIS File.
     thePrs - a PlotRecord Set that holds the seek positions of the appropriate
         LIS Logical Records (we only use CONS records here for the API header).
     theFpOut - Output file path for the SVG file(s), one per FILM ID.
     """
     assert(len(self._lgFormatS) > 0)
     _p, myLogPass, myCONSRecS = self._retPlotFromPlotRecordSet(theFi, thePrs)
     myFilm = FILMCfgXML.FilmCfgXMLRead()
     for aUniqueId in self._lgFormatS:
         logging.info('PlotLogPasses._plotUsingLgFormats(): UniqueId={:s}.'.format(aUniqueId))
         # Create a PRES like object from the UniqueId
         myRoot = myFilm.rootNode(aUniqueId)
         if myRoot is not None:
             myPres = PRESCfgXML.PresCfgXMLRead(myRoot, myFilm)
             myPlot = Plot.PlotReadXML(myFilm, myPres)
             if myPlot.hasDataToPlotLIS(myLogPass, aUniqueId):
                 # Create output path and plot it
                 myOutFilePath = '{:s}_{:04d}_{:s}.svg'.format(theFpOut, theLpIdx, aUniqueId)
                 myCurvIDs, numPoints = myPlot.plotLogPassLIS(
                         theFi,
                         myLogPass,
                         myLogPass.xAxisFirstEngVal,
                         myLogPass.xAxisLastEngVal,
                         aUniqueId,
                         open(myOutFilePath, 'w'),
                         frameStep=1,
                         title="Plot: {:s} LogPass: {:d} FILM ID={:s}".format(
                             os.path.abspath(myOutFilePath),
                             theLpIdx,
                             aUniqueId,
                         ),
                         lrCONS=myCONSRecS,
                     )
                 assert(myCurvIDs is not None and numPoints is not None)
                 # So here the essential data that we have to put in the index.html is:
                 # Key: myOutFilePath or input file fp, lpIdx, aFilmId,
                 # Value: (myPlot.xScale(aFilmId), myLogPass.xAxisFirstEngVal, myLogPass.xAxisLastEngVal, myCurvIDs)
                 self.plotLogInfo.addPlotResult(
                     theFi.fileId,
                     myOutFilePath,
                     theLpIdx,
                     aUniqueId,
                     myPlot.xScale(aUniqueId),
                     myLogPass.xAxisFirstEngVal,
                     myLogPass.xAxisLastEngVal,
                     theCurveS=myCurvIDs,
                     ptsPlotted=numPoints)
             else:
                 logging.error('PlotLogPasses._plotUsingLgFormats(): No root node for UniqueId: "{:s}"'.format(aUniqueId))
         else:
             logging.info('PlotLogPasses._plotUsingLgFormats(): No data to plot for FILM ID {:s}'.format(aUniqueId))
 def test_06(self):
     """PresCfgXMLRead.test_06(): create a PRESCfgXML.PresCfgXMLRead() from "Resistivity_3Track_Logrithmic.xml" outputs for destination."""
     myPcxr = PRESCfgXML.PresCfgXMLRead(
         self._fcxr,
         "Resistivity_3Track_Logrithmic.xml",
     )
     self.assertTrue(
         myPcxr.usesOutpChannel("Resistivity_3Track_Logrithmic.xml",
                                Mnem.Mnem('BS')))
     self.assertFalse(
         myPcxr.usesOutpChannel("Resistivity_3Track_Logrithmic.xml",
                                Mnem.Mnem('NOTBS')))
     self.assertFalse(
         myPcxr.usesOutpChannel("Resistivity_3Track_Logrithmic.xml", 'BS'))
    def test_08(self):
        """CurveCfgXMLRead.test_08(): tests single channel wrap mode UNKNOWN."""
        # Say in <LgTrack UniqueId="track1">
        xStr = """<LgCurve UniqueId="ROP5" xmlns="x-schema:LgSchema2.xml">
    <ChannelName>ROP5</ChannelName>
    <Color>0000FF</Color>
    <LeftLimit>500</LeftLimit>
    <RightLimit>0</RightLimit>
    <LineStyle>LG_DASH_LINE</LineStyle>
    <Thickness>1.75</Thickness>
    <WrapMode>UNKNOWN</WrapMode>
</LgCurve>"""
        root = etree.fromstring(xStr)
        myCcxr = PRESCfgXML.CurveCfgXMLRead(root, "track1", self._fcxr)
Exemple #7
0
def fileCurveMapFromFILM(theLpOrLasFile, theFilmCfg):
    """Returns a map of ``{FilmID : [OUTP, ...], ...}`` which is a list of OUTP in theLpOrLasFile
    that could be plotted with that film ID."""
    r = {}
    for uid in sorted(theFilmCfg.uniqueIdS()):
        myPresCfg = PRESCfgXML.PresCfgXMLRead(theFilmCfg, uid)
        try:
            myPhsFiCf = theFilmCfg[uid]
            outIdS = myPresCfg.outpChIDs(myPhsFiCf.name)
        except KeyError:
            pass
        else:
            r[uid] = [anO for anO in outIdS if theLpOrLasFile.hasOutpMnem(anO)]
    return r
    def test_06(self):
        """CurveCfgXMLRead.test_06(): tests single channel read logarithmic."""
        # Say in <LgTrack UniqueId="track1">
        xStr = """<LgCurve UniqueId="PSR" xmlns="x-schema:LgSchema2.xml">
            <ChannelName>PSR</ChannelName>
            <Color>00C000</Color>
            <LeftLimit>0.2</LeftLimit>
            <RightLimit>2000</RightLimit>
            <Thickness>2</Thickness>
            <Transform>LG_LOGARITHMIC</Transform>
            <WrapCount>0</WrapCount>
</LgCurve>"""
        root = etree.fromstring(xStr)
        myCcxr = PRESCfgXML.CurveCfgXMLRead(root, "track1", self._fcxr)
        self.assertFalse(myCcxr.mode is None)
    def test_05(self):
        """CurveCfgXMLRead.test_05(): tests single channel mode is linear."""
        # Say in <LgTrack UniqueId="track1">
        xStr = """<LgCurve UniqueId="Caliper" xmlns="x-schema:LgSchema2.xml">
    <ChannelName>CALI</ChannelName>
    <Color>FF0000</Color>
    <LeftLimit>6</LeftLimit>
    <LineStyle>LG_DASH_LINE</LineStyle>
    <RightLimit>16</RightLimit>
    <Thickness>2</Thickness>
    <WrapCount>1</WrapCount>
</LgCurve>"""
        root = etree.fromstring(xStr)
        myCcxr = PRESCfgXML.CurveCfgXMLRead(root, "track1", self._fcxr)
        self.assertTrue(myCcxr.mode is None)
    def test_00_02(self):
        """CurveCfgXMLRead.test_00_02(): tests low-level: _retBackup() UNKNOWN."""
        # Say in <LgTrack UniqueId="track1">
        xStr = """<LgCurve UniqueId="Cali" xmlns="x-schema:LgSchema2.xml">
    <ChannelName>CALI</ChannelName>
    <Color>FF0000</Color>
    <LeftLimit>6</LeftLimit>
    <LineStyle>LG_DASH_LINE</LineStyle>
    <RightLimit>16</RightLimit>
    <Thickness>2</Thickness>
    <WrapCount>1</WrapCount>
</LgCurve>"""
        root = etree.fromstring(xStr)
        myCcxr = PRESCfgXML.CurveCfgXMLRead(root, "track1", self._fcxr)
        myB = myCcxr._retBackup(
            etree.fromstring("""<LgCurve xmlns="x-schema:LgSchema2.xml">
    <WrapMode>UNKNOWN</WrapMode>
</LgCurve>"""))
        self.assertEqual((0, 0), myB)
 def test_05(self):
     """PresCfgXMLRead.test_05(): create a PRESCfgXML.PresCfgXMLRead() from "Resistivity_3Track_Logrithmic.xml" outputs for destination."""
     myPcxr = PRESCfgXML.PresCfgXMLRead(
         self._fcxr,
         "Resistivity_3Track_Logrithmic.xml",
     )
     self.assertEqual(
         1,
         len(
             myPcxr.outpCurveIDs("Resistivity_3Track_Logrithmic.xml",
                                 Mnem.Mnem('BS'))),
     )
     self.assertEqual(
         [
             'BS_7',
         ],
         myPcxr.outpCurveIDs("Resistivity_3Track_Logrithmic.xml",
                             Mnem.Mnem('BS')),
     )
    def test_11(self):
        """CurveCfgXMLRead.test_11(): tests single colour OK."""
        # Say in <LgTrack UniqueId="track1">
        xStr = """<LgCurve UniqueId="ROP5" xmlns="x-schema:LgSchema2.xml">
    <ChannelName>ROP5</ChannelName>
    <Color>0000FF</Color>
    <LeftLimit>500</LeftLimit>
    <RightLimit>0</RightLimit>
    <LineStyle>LG_DASH_LINE</LineStyle>
    <Thickness>1.75</Thickness>
    <WrapMode>LG_LEFT_WRAPPED</WrapMode>
</LgCurve>"""
        root = etree.fromstring(xStr)
        myCcxr = PRESCfgXML.CurveCfgXMLRead(root, "track1", self._fcxr)
        self.assertEqual(
            Stroke.Stroke(width=0.5,
                          colour='rgb(0,0,255)',
                          coding=(4, 4),
                          opacity=1.0),
            myCcxr.codiStroke,
        )
    def test_00_11(self):
        """CurveCfgXMLRead.test_00_11(): tests low-level: _retCoding()."""
        # Say in <LgTrack UniqueId="track1">
        xStr = """<LgCurve UniqueId="Cali" xmlns="x-schema:LgSchema2.xml">
    <ChannelName>CALI</ChannelName>
    <Color>FF0000</Color>
    <LeftLimit>6</LeftLimit>
    <LineStyle>LG_DASH_LINE</LineStyle>
    <RightLimit>16</RightLimit>
    <Thickness>2</Thickness>
    <WrapCount>1</WrapCount>
</LgCurve>"""
        root = etree.fromstring(xStr)
        myCcxr = PRESCfgXML.CurveCfgXMLRead(root, "track1", self._fcxr)
        myV = myCcxr._retCoding(
            etree.fromstring("""<LgCurve xmlns="x-schema:LgSchema2.xml">
    <Color>FF0000</Color>
    <LineStyle>LG_DASH_LINE</LineStyle>
</LgCurve>"""))
        self.assertEqual(
            Stroke.Stroke(width=0.5,
                          colour='rgb(255,0,0)',
                          coding=(4, 4),
                          opacity=1.0), myV)
 def test_04(self):
     """PresCfgXMLRead.test_04(): create a PRESCfgXML.PresCfgXMLRead() from "Resistivity_3Track_Logrithmic.xml" outputs for destination."""
     myPcxr = PRESCfgXML.PresCfgXMLRead(
         self._fcxr,
         "Resistivity_3Track_Logrithmic.xml",
     )
     self.assertTrue(
         myPcxr.hasCurvesForDest("Resistivity_3Track_Logrithmic.xml"))
     #        print()
     #        print(sorted(myPcxr.outpChIDs("Resistivity_3Track_Logrithmic.xml")))
     #        pprint.pprint(sorted(myPcxr.outpChIDs("Resistivity_3Track_Logrithmic.xml")))
     self.assertEqual(
         43, len(myPcxr.outpChIDs("Resistivity_3Track_Logrithmic.xml")))
     exp = [
         Mnem.Mnem(m) for m in [
             'A22H',
             'A34H',
             'AHF10',
             'AHF20',
             'AHF30',
             'AHF60',
             'AHF90',
             'AHO10',
             'AHO20',
             'AHO30',
             'AHO60',
             'AHO90',
             'AHT10',
             'AHT20',
             'AHT30',
             'AHT60',
             'AHT90',
             'ATR',
             'BS',
             'CALI',
             'GR',
             'HCAL',
             'ILD',
             'ILM',
             'LLD',
             'LLM',
             'MSFL',
             'P16H_RT',
             'P28H_RT',
             'P34H_RT',
             'PCAL',
             'PSR',
             'RLA0',
             'RLA1',
             'RLA2',
             'RLA3',
             'RLA4',
             'RLA5',
             'ROP5',
             'RXO',
             'SFL',
             'SP',
             'TENS',
         ]
     ]
     act = sorted([
         str(v)
         for v in myPcxr.outpChIDs("Resistivity_3Track_Logrithmic.xml")
     ])
     self.assertEqual(exp, act)
 def test_01(self):
     """PresCfgXMLRead.test_01(): create a PRESCfgXML.PresCfgXMLRead() from "Resistivity_3Track_Logrithmic.xml"."""
     PRESCfgXML.PresCfgXMLRead(
         self._fcxr,
         "Resistivity_3Track_Logrithmic.xml",
     )