How to use _has_header method in localstack

Best Python code snippet using localstack_python

PGAALibraries.py

Source:PGAALibraries.py Github

copy

Full Screen

1# PGAA database from Institute of Isotopes, Hungarian Academey of Science,2# Budapest3from uncertainties import ufloat, ufloat_fromstr4from hdtv.database.common import *5import hdtv.cmdline6import hdtv.ui7class PGAAGamma(Gamma):8 """9 Store data about PGAA gammas10 k0_comp is the comparator element for k0 values which k0 should be normed to 1.011 given as tuple (Z, A) (default: 1-H)12 """13 k0_norm = None14 __slots__ = ("ID", "nuclide", "energy", "sigma", "intensity", "halflife", "_k0")15 def __init__(16 self,17 nuclide,18 energy,19 sigma=None,20 intensity=None,21 k0=None,22 halflife=None,23 k0_comp=(1, 1),24 ):25 super().__init__(nuclide, energy, sigma, intensity)26 self.halflife = halflife27 self._k0 = k0 # TODO28 if nuclide == Nuclides(k0_comp[0], k0_comp[1])[0] and not PGAAGamma.k0_norm:29 # Normalize reference element to k0=1.030 PGAAGamma.k0_norm = 1.0 / self.getk0(isNorm=True)31 def getk0(self, isNorm=False):32 if self._k0 is None: # k0 was not given: we have to calculate33 if isNorm:34 k0 = self.sigma / self.nuclide.element.m35 else:36 try:37 k0 = (self.sigma / self.nuclide.element.m) * PGAAGamma.k0_norm38 except TypeError:39 k0 = None40 return k041 else:42 return self._k043 k0 = property(getk0)44 def __str__(self):45 text = ""46 text += super().__str__()47 text += "k0: " + str(self.k0) + "\n"48 return text49class PGAAlib_IKI2000(GammaLib):50 """51 PGAA library of the Institute of Isotopes, Hungarian Academy of Sciences, Budapest52 """53 def __init__(54 self,55 csvfile=os.path.join(hdtv.datadir, "PGAAlib-IKI2000.dat"),56 has_header=True,57 k0_comp=(1, 1),58 ):59 super().__init__()60 # Header for table printout61 self.fOrderedHeader = [62 "Z",63 "A",64 "El",65 "Energy/(keV)",66 "Intensity",67 "Sigma/(b)",68 "k0",69 "Halflife/(s)",70 ]71 # Conversion functions for parameter72 self.fParamConv = {73 "z": int,74 "a": int,75 "symbol": str,76 "energy": float,77 "intensity": float,78 "sigma": float,79 "k0": float,80 "halflife": float,81 }82 self.name = "PGAAlib_IKI2000"83 self.description = (84 "PGAA database, Inst. of Isotopes, Hungarian Academey of Science"85 )86 self.csvfile = csvfile87 self._has_header = has_header88 self.k0_comp = k0_comp89 def open(self):90 if self.opened:91 return True92 try:93 datfile = open(self.csvfile, encoding="utf-8")94 except TypeError:95 datfile = open(self.csvfile, "rb")96 reader = csv.reader(datfile)97 if self._has_header:98 next(reader)99 try:100 for line in reader:101 Z = int(line[0])102 A = int(line[1])103 energy = ufloat(float(line[2]), float(line[3]))104 sigma = ufloat(float(line[4]), float(line[5]))105 intensity = ufloat(float(line[6]), 0) / 100.0106 try:107 halflife = ufloat(float(line[7]), 0)108 except ValueError:109 halflife = None110 gamma = PGAAGamma(111 Nuclides(Z, A)[0],112 energy,113 sigma=sigma,114 intensity=intensity,115 halflife=halflife,116 k0_comp=self.k0_comp,117 )118 self.append(gamma)119 except csv.Error as e:120 raise HDTVCommandAbort(121 "file %s, line %d: %s" % (self.csvfile, reader.line_num, e)122 )123 else:124 self.opened = True125 finally:126 datfile.close()127class PromptGammas(GammaLib):128 """129 Extensive IAEA Prompt-Gamma library130 """131 def __init__(132 self,133 csvfile=os.path.join(hdtv.datadir, "PromptGammas.dat"),134 has_header=True,135 k0_comp=(1, 1),136 ):137 super().__init__()138 # Header for table printout139 self.fOrderedHeader = ["Z", "A", "El", "Energy/(keV)", "Sigma/(b)", "k0"]140 # Conversion functions for parameter141 self.fParamConv = {142 "z": int,143 "a": int,144 "symbol": str,145 "energy": float,146 "sigma": float,147 "k0": float,148 }149 self.name = "PromptGammas"150 self.description = "Extensive Prompt-Gamma library"151 self.csvfile = csvfile152 self._has_header = has_header153 self.k0_comp = k0_comp154 def open(self):155 if self.opened:156 return True157 try:158 datfile = open(self.csvfile, encoding="utf-8")159 except TypeError:160 datfile = open(self.csvfile, "rb")161 reader = csv.reader(datfile)162 if self._has_header:163 next(reader)164 try:165 for line in reader:166 A = int(line[0])167 Z = int(line[1])168 energy = ufloat_fromstr(line[2])169 sigma = ufloat_fromstr(line[3])170 k0 = ufloat_fromstr(line[4])171 gamma = PGAAGamma(172 Nuclides(Z, A)[0], energy, sigma=sigma, k0=k0, k0_comp=self.k0_comp173 )174 self.append(gamma)175 except csv.Error as e:176 hdtv.ui.error("file %s, line %d: %s" % (self.csvfile, reader.line_num, e))177 else:178 self.opened = True179 finally:...

Full Screen

Full Screen

topic_fill_header_publisher.py

Source:topic_fill_header_publisher.py Github

copy

Full Screen

1import rospy2import topic_publisher3import tf2_msgs.msg4class TopicFillHeaderPublisher(topic_publisher.TopicPublisher):5 def __init__(self, topic_name, message_class):6 super(TopicFillHeaderPublisher, self).__init__(7 topic_name, message_class)8 self._is_tf = False9 if message_class == tf2_msgs.msg.TFMessage:10 self._is_tf = True11 self._has_header = False12 if hasattr(self._message, 'header'):13 if hasattr(self._message.header, 'stamp'):14 self._has_header = True15 def publish(self):16 if self._is_tf:17 now = rospy.Time.now()18 for transform in self._message.transforms:19 transform.header.stamp = now20 if self._has_header:21 self._message.header.stamp = rospy.Time.now()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful