本文整理匯總了Python中admit.util.AdmitLogging.AdmitLogging.warning方法的典型用法代碼示例。如果您正苦於以下問題:Python AdmitLogging.warning方法的具體用法?Python AdmitLogging.warning怎麽用?Python AdmitLogging.warning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類admit.util.AdmitLogging.AdmitLogging
的用法示例。
在下文中一共展示了AdmitLogging.warning方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_warning
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def test_warning(self):
msg = "unit_test_warning_message"
Alogging.warning(msg)
found = False
r = open(self.logfile, 'r')
for line in r.readlines():
if msg in line:
if(self.verbose):
print "\nFound message >", line
found = True
r.close()
break
# since this is the last test case, we now close off the logging
Alogging.shutdown()
try:
if os.path.exists(self.logfile):
os.remove(self.logfile)
except RuntimeError:
pass
self.assertTrue(found)
示例2: admit_root
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def admit_root(path = None):
""" Return the root directory of the ADMIT environment
Typically in ADMIT/etc there are files needed by certain functions
and other TBD locations.
For now we are using getenv(), but in deployment this may not
be the case.
Parameters
----------
path : string
Optional path appended to the ADMIT root
Returns
-------
String containing the absolute address of the admit root directory,
with the optional path appended
"""
global _admit_root
if _admit_root != None: return _admit_root
# try the old style developer environment first
_admit_root = os.getenv("ADMIT")
if _admit_root == None:
# try the dumb generic way; is that safe to reference from __file__ ???
_admit_root = version.__file__.rsplit('/',2)[0]
if _admit_root[0] != '/':
logging.warning("ADMIT_ROOT is a relative address")
# @tdodo shouldn't that be a fatal error
#
print "_ADMIT_ROOT=",_admit_root
if path == None:
return _admit_root
return _admit_root + '/' + path
示例3: mask_outside
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def mask_outside(self, limit1, limit2, axis="spec"):
""" Method to mask any data less than or greater than the given values.
Any axis can be used ("spec", "freq", "chans") as
the basis for the masking.
Parameters
----------
limit1 : float or int
The value below which all data of the given axis
will be masked.
limit2 : float or int
The value above which all data of the given axis
will be masked.
axis : str
The axis which is used to determine the flags.
Default: "spec"
Returns
-------
None
"""
if not self.integritycheck():
logging.warning(" Masking operation not performed.")
return
mask1 = getattr(self, "_" + axis, None) < limit1
mask2 = limit2 < getattr(self, "_" + axis, None)
mask = np.logical_and(mask1, mask2)
self._mask = np.logical_or(self._mask, mask)
示例4: mask_ge
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def mask_ge(self, limit, axis="spec"):
""" Method to mask any data less than or equal to the given value.
Any axis can be used ("spec", "freq", "chans") as
the basis for the masking.
Parameters
----------
limit : float or int
The value which all data, of the given axis,
greater than or equal to, will be masked.
axis : str
The axis which is used to determine the flags.
Default: "spec"
Returns
-------
None
"""
if not self.integritycheck():
logging.warning(" Masking operation not performed.")
return
mask = getattr(self, "_" + axis, None) >= limit
self._mask = np.logical_or(self._mask, mask)
示例5: set_mask
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def set_mask(self, mask):
""" Method to set the mask item
Parameters
----------
mask : array like or bool
The mask to use, must be equal in dimmension to
the spectral axis, or a single boolean value which
is applied to all data.
Returns
-------
None
"""
tempmask = self._mask
if isinstance(mask, ma.masked_array):
if len(self._spec) > len(mask) > 1:
raise
elif len(mask) == 1:
self._mask = np.array([mask.data[0]] * len(self._spec))
else:
self._mask = np.array(mask.data)
elif isinstance(mask, list) or isinstance(mask, np.ndarray):
if len(self._spec) > len(mask) > 1:
raise
elif len(mask) == 1:
self._mask = np.array([mask[0]] * len(self._spec))
else:
self._mask = np.array(mask)
if self.integritycheck():
return
logging.warning(" Mask not applied")
self._mask = tempmask
示例6: __init__
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def __init__(self, upper=True):
self.version = "27-apr-2016"
if have_ADMIT:
self.table = utils.admit_root() + "/etc/vlsr.tab"
self.cat = read_vlsr(self.table,upper)
logging.debug("VLSR: %s, found %d entries" % (self.table,len(self.cat)))
else:
logging.warning("VLSR: Warning, no ADMIT, empty catalogue")
self.cat = {}
示例7: characters
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def characters(self, ch):
""" Method called whenever characters are detected in an xml node
This method does some dtd validation. This
method is only called by the SAX parser iteself.
Parameters
----------
ch : unicode characters
Returns
-------
None
"""
target = None
char = str(ch).strip()
if char.isspace() or not char:
return
# determine which class the data are getting writtrn to
if self.inUtil:
target = self.Util
elif self.inBDP:
target = self.BDP
elif self.inAT:
target = self.curAT
elif self.inSummaryEntry:
target = self.summaryEntry
elif self.inSummary:
target = self.summaryData
else:
target = self.admit
# a list or dictionary has to be decoded
if isinstance(self.type, list) or isinstance(self.type, dict) \
or isinstance(self.type, tuple) or isinstance(self.type, set) \
or isinstance(self.type, np.ndarray) or isinstance(self.type, str):
if self.inflow:
self.flowdata += char
else:
self.tempdata += char
else:
# check the version
if self.name == "_version":
ver = self.getattr(target, self.name)
vercheck = utils.compareversions(ver, str(char))
if vercheck < 0: # newer read in
logging.warning("Version mismatch for %s, data are a newer version than current software, attempting to continue." % target.getkey("_type"))
elif vercheck > 0: # older read in
logging.warning("Version mismatch for %s, data are an older version than current software, attempting to continue." % target.getkey("_type"))
else:
try:
self.setattr(target, self.name, self.getData(char))
except AttributeError:
logging.info("Data member %s is not a member of %s. This may be due to a version mismatch between the data and your software, attempting to continue." % (self.name, str(type(target))))
except:
raise
del ch
示例8: mask_invalid
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def mask_invalid(self):
""" Method to mask all invalid spectral data.
Invalid values are: NaN, Inf, -Inf
Parameters
----------
None
Returns
-------
None
"""
if not self.integritycheck():
logging.warning(" Masking operation not performed.")
return
mask = np.isfinite(self._spec)
self._mask = np.logical_or(self._mask, np.logical_not(mask))
示例9: fix_invalid
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def fix_invalid(self, mask_value=0.0):
""" Method to replace invalid spectral data with a specific value
and mask it. Invalid values are: NaN, Inf, -Inf
Parameters
----------
mask_value : float
The value to replace the invalid data with.
Default: 0.0
Returns
-------
None
"""
if not self.integritycheck():
logging.warning(" Masking operation not performed.")
return
mask = np.isfinite(self._spec)
for i in range(len(mask)):
if not mask[i]:
self._spec[i] = mask_value
self._mask = np.logical_or(self._mask, np.logical_not(mask))
示例10: run
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def run(self):
""" running the File_AT task
"""
# grab and check essential keywords
filename = self.getkey('file')
logging.info("file=%s" % filename)
if len(filename) == 0:
raise Exception,'File_AT: no file= given'
exist = self.getkey('exist')
if exist:
#
logging.warning("no checking now")
# self._bdp_in[0].checkfiles()
# create the BDP
bdp1 = File_BDP(filename)
bdp1.filename = filename
self.addoutput(bdp1)
# touch the file if desired
if self.getkey('touch'): bdp1.touch()
示例11: integritycheck
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def integritycheck(self):
""" Method to check that all axes are the same length. Axes
that have no data are ignored.
Parameters
----------
None
Returns
-------
Bool, True if all match, False if there is an inconsistency
"""
if self._spec is not None:
ls = len(self._spec)
else:
ls = 0
if self._freq is not None:
lf = len(self._freq)
else:
lf = ls
if self._chans is not None:
lc = len(self._chans)
else:
lc = ls
if self._mask is not None:
lm = len(self._mask)
else:
lm = ls
if self._contin is not None:
lco = len(self._contin)
else:
lco = ls
if ls == lf == lc == lm == lco:
return True
logging.warning("Inconsistent axes: spectrum: %i, freq: %i, chans: %i, mask: %i, contin: %i" % (ls, lf, lc, lm, lco))
return False
示例12: parse_response
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def parse_response(self):
""" Parse a response (of type urllib2.urlopen) into a list of dictionaries.
Parameters
----------
None
Returns
-------
A dictonary of the response
"""
result = []
response = self.response
try:
csvstring = response.read()
tablelist = csvstring.split('\n')
header = tablelist[0]
headerlist = header.split(':')
headerlist = clean_column_headings(headerlist, renaming_dict=column_headings_map)
#Populate list of dictionaries
for row in tablelist[1:-1]:
rowlist = row.split(':')
rowdict = {}
for i in range(0, len(rowlist)):
rowdict[headerlist[i]] = rowlist[i]
result.append(rowdict)
except:
logging.warning("Problem parsing result")
self.result = result
return result
示例13: run
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
#.........這裏部分代碼省略.........
if nrargs > 0:
# need to get the peaks without rubust
imstat10 = casa.imstat(self.dir(fin), logfile=self.dir('imstat0.logfile'),append=True)
dt.tag("imstat10")
imstat11 = casa.imstat(self.dir(fin),axes=[0,1],logfile=self.dir('imstat1.logfile'),append=True)
dt.tag("imstat11")
# grab the relevant plane-based things from imstat1
if nrargs == 0:
mean = imstat1["mean"]
sigma = imstat1["medabsdevmed"]*1.4826 # see also: astropy.stats.median_absolute_deviation()
peakval = imstat1["max"]
minval = imstat1["min"]
else:
mean = imstat1["mean"]
sigma = imstat1["rms"]
peakval = imstat11["max"]
minval = imstat11["min"]
if True:
# work around a bug in imstat(axes=[0,1]) for last channel [CAS-7697]
for i in range(len(sigma)):
if sigma[i] == 0.0:
minval[i] = peakval[i] = 0.0
# too many variations in the RMS ?
sigma_pos = sigma[np.where(sigma>0)]
smin = sigma_pos.min()
smax = sigma_pos.max()
logging.info("sigma varies from %f to %f; %d/%d channels ok" % (smin,smax,len(sigma_pos),len(sigma)))
if maxvrms > 0:
if smax/smin > maxvrms:
cliprms = smin * maxvrms
logging.warning("sigma varies too much, going to clip to %g (%g > %g)" % (cliprms, smax/smin, maxvrms))
sigma = np.where(sigma < cliprms, sigma, cliprms)
# @todo (and check again) for foobar.fits all sigma's became 0 when robust was selected
# was this with mask=True/False?
# PeakPointPlot (can be expensive, hence the option)
if use_ppp:
logging.info("Computing MaxPos for PeakPointPlot")
xpos = np.zeros(nchan)
ypos = np.zeros(nchan)
peaksum = np.zeros(nchan)
ia.open(self.dir(fin))
for i in range(nchan):
if sigma[i] > 0.0:
plane = ia.getchunk(blc=[0,0,i,-1],trc=[-1,-1,i,-1],dropdeg=True)
v = ma.masked_invalid(plane)
v_abs = np.absolute(v)
max = np.unravel_index(v_abs.argmax(), v_abs.shape)
xpos[i] = max[0]
ypos[i] = max[1]
if numsigma > 0.0:
peaksum[i] = ma.masked_less(v,numsigma * sigma[i]).sum()
peaksum = np.nan_to_num(peaksum) # put 0's where nan's are found
ia.close()
dt.tag("ppp")
nzeros = len(np.where(sigma<=0.0))
if nzeros > 0:
zeroch = np.where(sigma<=0.0)
logging.warning("There are %d fully masked channels (%s)" % (nzeros,str(zeroch)))
示例14: _parse_kwargs
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def _parse_kwargs(self, min_frequency=None, max_frequency=None,
band='any', top20=None, chemical_name=None,
chem_re_flags=0, energy_min=None, energy_max=None,
energy_type=None, intensity_lower_limit=None,
intensity_type=None, transition=None, version=None,
exclude=None, only_NRAO_recommended=None,
line_lists=None, line_strengths=None, energy_levels=None,
export=None, export_limit=None, noHFS=None,
displayHFS=None, show_unres_qn=None,
show_upper_degeneracy=None, show_molecule_tag=None,
show_qn_code=None, show_lovas_labref=None,
show_lovas_obsref=None, show_orderedfreq_only=None,
show_nrao_recommended=None, fel=None):
# set the payload of the http request
payload = {'submit': 'Search',
'frequency_units': 'GHz',
}
# set the band or frequency ranges
if band != 'any':
if band not in self.FREQUENCY_BANDS:
raise ValueError("Invalid frequency band.")
if min_frequency is not None or max_frequency is not None:
logging.warning("Band was specified, so the frequency specification is overridden")
payload['band'] = band
elif min_frequency is not None and max_frequency is not None:
if min_frequency > max_frequency:
min_frequency, max_frequency = max_frequency, min_frequency
#ASSUMES UNITS OF GHz
payload['from'] = min_frequency
payload['to'] = max_frequency
# select the top20 list if given
if top20 is not None and len(top20) > 0:
if top20 in self.TOP20_LIST:
payload['top20'] = top20
else:
raise ValueError("Top20 is not one of the allowed values")
# set the chemical name if given
elif chemical_name in ('', {}, (), [], set()):
# include all
payload['sid[]'] = []
elif chemical_name is not None:
# encode the chemical names to species id's
species_ids = self.get_species_ids(chemical_name, chem_re_flags)
if len(species_ids) == 0:
raise ValueError("No matching chemical species found.")
payload['sid[]'] = list(species_ids.values())
# set the min an max energy range and untis
if energy_min is not None:
payload['energy_range_from'] = float(energy_min)
if energy_max is not None:
payload['energy_range_to'] = float(energy_max)
if energy_type is not None:
payload['energy_range_type'] = energy_type
# set the minimum intensity and units
if intensity_type is not None:
payload['lill'] = 'lill_' + intensity_type
if intensity_lower_limit is not None:
payload[payload['lill']] = intensity_lower_limit
# set the specific transition
if transition is not None:
payload['tran'] = transition
# set the version id
if version in self.versions:
payload['version'] = version
elif version is not None:
raise ValueError("Invalid version specified. Allowed versions are {vers}".format(vers=str(self.versions)))
# set which types to exclude
if exclude is not None:
for e in exclude:
payload['no_' + e] = 'no_' + e
# set the NRAO recommended frequencies option
if only_NRAO_recommended:
payload['include_only_nrao'] = 'include_only_nrao'
# set any line lists to use
if line_lists is not None and len(line_lists) > 0:
if type(line_lists) not in (tuple, list):
raise TypeError("Line lists should be a list of linelist names. See Splatalogue.ALL_LINE_LISTS")
for L in self.ALL_LINE_LISTS:
kwd = 'display' + L
if L in line_lists:
payload[kwd] = kwd
else:
payload[kwd] = ''
# set which line strengths to return
if line_strengths is not None:
for LS in line_strengths:
payload[LS] = LS
#.........這裏部分代碼省略.........
示例15: __init__
# 需要導入模塊: from admit.util.AdmitLogging import AdmitLogging [as 別名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import warning [as 別名]
def __init__(self, st=None, en=None, nchan=None, startchan=0):
# initialize everything
self._segments = []
self._nchan = nchan
# error chack the starting channel number
self._startchan = int(startchan)
if self._startchan < 0:
raise Exception("Start channel must be 0 or greater.")
# if nchan was specified create the bitmask
if nchan:
self._chans = np.array([0] * nchan)
# determine the maxchan
self._maxchan = nchan - 1 + self._startchan
else:
self._chans = None
self._maxchan = 0
if st is None:
return
if type(st) != type(en) and en is not None:
raise Exception("Channel start and end points must be the same type.")
# build the list of segments
# if en is not given
peak = 0
if en is None:
# st must be array like
if not hasattr(st, '__iter__'):
raise Exception("A list must be given for parameter st.")
for seg in st:
# each one must have length of 2
if len(seg) != 2:
raise Exception("Each segment must have a size of 2.")
# make sure they are in the right order
tempseg = [int(seg[0]), int(seg[1])]
tempseg.sort()
peak = max(peak, tempseg[1])
self._segments.append(tempseg)
else:
# if both en and st are given and are ints
if not hasattr(st, '__iter__'):
tempseg = [int(st), int(en)]
tempseg.sort()
peak = max(peak, tempseg[1])
self._segments.append(tempseg)
else:
# if both en ans st are given and both array like
# create iterators
stit = iter(st)
enit = iter(en)
if len(st) != len(en):
logging.warning("Starting and ending channel ranges do not have the same length, truncating the longer.")
# iterate through the lists
while True:
try:
tempseg = [int(stit.next()), int(enit.next())]
tempseg.sort()
peak = max(peak, tempseg[1])
self._segments.append(tempseg)
except StopIteration:
break
if self._chans is None:
self._chans = np.array([0] * (peak + 1))
# determine the maxchan
self._maxchan = peak + self._startchan
# build the bit mask
for seg in self._segments:
if seg[1] > self._maxchan or seg[0] < self._startchan:
raise Exception("All or part of a segment is beyond the given spectrum. Segment: %s, bounds: [%i, %i]" %
(seg, self._startchan, self._maxchan))
self._chans[seg[0] - self._startchan: seg[1] - self._startchan + 1] = 1