/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Private Member Functions
Scraper::adwphv::AdWpHvScraper Class Reference
Inheritance diagram for Scraper::adwphv::AdWpHvScraper:
Inheritance graph
[legend]
Collaboration diagram for Scraper::adwphv::AdWpHvScraper:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def changed
def propagate
def seed

Private Member Functions

def _detectordict
def _getsite
def _getdet

Detailed Description

Definition at line 140 of file adwphv.py.


Member Function Documentation

def Scraper::adwphv::AdWpHvScraper::changed (   self,
  sv 
)
:param sv: source vector instance :py:class:`Scraper.base.sourcevector.SourceVector` 

Decide if sufficient change to propagate based on differences between the first and last elements of `SourceVector` instance argument

Definition at line 141 of file adwphv.py.

00142                            :
00143         """
00144         :param sv: source vector instance :py:class:`Scraper.base.sourcevector.SourceVector` 
00145 
00146         Decide if sufficient change to propagate based on differences between the first and last elements of `SourceVector` instance argument
00147         """
00148 
00149         p = self._detectordict( sv[0] )
00150         c = self._detectordict( sv[-1] )
00151         site = p.pop('site')
00152         det = p.pop('det')['det']
00153         if det.find("MUO") == 0:
00154             subsite = p.pop('subsite')
00155         for label in sorted(p.keys()):
00156             pv = p[label]
00157             cv = c[label]
00158             if abs(pv['voltage']-cv['voltage']) > self.threshold:
00159                 log.info( "Changed bc voltage changed for {} from {} to {}".format(label,pv['voltage'],cv['voltage']))
00160                 return True
00161         return False

def Scraper::adwphv::AdWpHvScraper::propagate (   self,
  sv 
)
:param sv: source vector instance :py:class:`Scraper.base.sourcevector.SourceVector` 

Yield write ready DybDbi target dicts to base class, note that a single source vector
instance is yielding multiple target dicts. The keys of the target dict must match
the specified attributes of the ``DybDbi`` target class. 

Here the output is based entirely on the last element of the source vector. A smarter
implementation might average the first and last to smooth variations.
The python ``yield`` command makes it possible to iterate over a what is returned by 
a function/method.

ETW Aug 2012: write voltage from sv[0], NOT sv[-1]

Definition at line 162 of file adwphv.py.

00163                             :
00164         """
00165         :param sv: source vector instance :py:class:`Scraper.base.sourcevector.SourceVector` 
00166 
00167         Yield write ready DybDbi target dicts to base class, note that a single source vector
00168         instance is yielding multiple target dicts. The keys of the target dict must match
00169         the specified attributes of the ``DybDbi`` target class. 
00170 
00171         Here the output is based entirely on the last element of the source vector. A smarter
00172         implementation might average the first and last to smooth variations.
00173         The python ``yield`` command makes it possible to iterate over a what is returned by 
00174         a function/method.
00175 
00176         ETW Aug 2012: write voltage from sv[0], NOT sv[-1]
00177 
00178         """
00179 
00180         dd = self._detectordict(sv[0])
00181         n = 0
00182         site = dd.pop('site')
00183         det = dd.pop('det')
00184         detval = det['det']
00185         if detval.find("MUO") == 0:
00186             sub = dd.pop('subsite')
00187         for label,v in sorted(dd.items()):
00188             d = dict(LocationId=label,Voltage=float(v['voltage']))
00189             n += 1
00190             yield d
            
def Scraper::adwphv::AdWpHvScraper::seed (   self,
  sc 
)
Used for seeding target DB when testing into empty tables

:param sc: source class, potentially different seeds will be needed 
   for each source that feeds into a single target

Definition at line 191 of file adwphv.py.

00192                       :
00193         """
00194         Used for seeding target DB when testing into empty tables
00195 
00196         :param sc: source class, potentially different seeds will be needed 
00197                    for each source that feeds into a single target
00198         """
00199         #ETW 10/09/2012 Add AD7 and AD8
00200 
00201         scstr=str(sc)
00202         
00203         if scstr.find("AD1") > 0:
00204             return dict(LocationId="L1C1R1",Voltage=0)
00205         if scstr.find("AD2") > 0:
00206             return dict(LocationId="L1C1R1",Voltage=0)
00207         if scstr.find("AD3") > 0:
00208             return dict(LocationId="L1C1R1",Voltage=0)
00209         if scstr.find("AD4") > 0:
00210             return dict(LocationId="L1C1R1",Voltage=0)
00211         if scstr.find("AD5") > 0:
00212             return dict(LocationId="L1C1R1",Voltage=0)
00213         if scstr.find("AD6") > 0:
00214             return dict(LocationId="L1C1R1",Voltage=0)
00215         if scstr.find("AD7") > 0:
00216             return dict(LocationId="L1C1R1",Voltage=0)
00217         if scstr.find("AD8") > 0:
00218             return dict(LocationId="L1C1R1",Voltage=0)        
00219         if scstr.find("DBNS_MUON") > 0:
00220             if scstr.find("IWS") > 0:
00221                 return dict(LocationId="DCIU3G",Voltage=0)
00222             else:
00223                 return dict(LocationId="DVIU26",Voltage=0)
00224         if scstr.find("LANS_MUON") > 0:
00225             if scstr.find("IWS") > 0:
00226                 return dict(LocationId="LCIU3G",Voltage=0)
00227             else:
00228                 return dict(LocationId="LVIU26",Voltage=0)
00229         if scstr.find("FARS_MUON") > 0:
00230             if scstr.find("IWS") > 0:
00231                 return dict(LocationId="FCIU3D",Voltage=0)
00232             else:
00233                 return dict(LocationId="FVIA14",Voltage=0)

def Scraper::adwphv::AdWpHvScraper::_detectordict (   self,
  inst 
) [private]
:param inst: SQLAlchemy source instance

Examines source instance, extracting detector name, DCS detector id, and values into a dict.

Definition at line 234 of file adwphv.py.

00235                                 :
00236         """
00237         :param inst: SQLAlchemy source instance
00238 
00239         Examines source instance, extracting detector name, DCS detector id, and values into a dict.
00240         """
00241 
00242         #ETW 10/08/12 Separate IWS/OWS here now
00243 
00244         dd={}
00245         inststr = str(inst)
00246         sitestr = inststr[1:4]
00247         detstr = inststr[6:9]
00248         dd['site'] = {'site':sitestr}
00249         dd['det'] = {'det':detstr}
00250         if (detstr == 'MUO'):
00251             kptn = re.compile("^(?P<hall>[DLF])(?P<pool>[CV])(?P<facing>[IO])(?P<wall>[ABCDEFGHU])(?P<row>\d)(?P<col>\d)$")
00252             subsitestr = inststr[11:14]
00253             dd['subsite'] = {'subsite':subsitestr}
00254             for k,v in inst.asdict.items():
00255                 if k in 'id date_time'.split():
00256                     continue
00257                 m = kptn.match(k)
00258                 if m:
00259                     d = m.groupdict()
00260                     pool = d['pool']
00261                     if ('IWS' in subsitestr and pool != 'C'):
00262                         continue
00263                     if ('OWS' in subsitestr and pool != 'V'):
00264                         continue
00265                     #log.info("subsitestr= {}, pool = {}".format(subsitestr,pool))
00266                     if v is None:
00267                         v = -999
00268                     qty,kk = ('voltage',k)
00269                     if dd.has_key(kk):
00270                         dd[kk].update({qty:v})
00271                     else:
00272                         dd[kk] = {qty:v}
00273         else:
00274             for k,v in inst.asdict.items():
00275                 if k in 'id date_time'.split():
00276                     continue
00277                 if v is None:
00278                     v = -999
00279                 qty,kk = ('voltage',k)
00280                 if dd.has_key(kk):
00281                     dd[kk].update({qty:v})
00282                 else:
00283                     dd[kk] = {qty:v}
00284         return dd

def Scraper::adwphv::AdWpHvScraper::_getsite (   self,
  site 
) [private]
Returns ksite number given string input

Definition at line 285 of file adwphv.py.

00286                            :
00287         """
00288         Returns ksite number given string input
00289         """
00290 
00291         if site == 'DBN':
00292             return SiteFromString("DayaBay")
00293         elif site == 'LAN':
00294             return SiteFromString("LingAo")
00295         elif site == 'FAR':
00296             return SiteFromString("Far")
00297         else:
00298             msg = "Do not recognize site...must be DBNS, LANS, or FARS"
00299             log.fatal(msg)
00300             raise Exception(msg)
00301             return -1

def Scraper::adwphv::AdWpHvScraper::_getdet (   self,
  det 
) [private]
Returns detector number given string input

Definition at line 302 of file adwphv.py.

00303                          :
00304         """
00305         Returns detector number given string input
00306         """
00307 
00308         #ETW 11/07/2012 Use AdLogicalPhysical instead of hardwired mapping
00309         if "AD" in det:
00310             alp = AdLogicalPhysical()
00311             detnum = int(det[2])
00312             site,det = alp(detnum)
00313             return det
00314         else:
00315             msg = "Do not recognize detector...must be AD1-AD8"
00316             log.fatal(msg)
00317             raise Exception(msg)
00318             return -1


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:50:03 for Scraper by doxygen 1.7.4