Functions | Variables
modify_metadata_with_upmu_sample_type Namespace Reference

Functions

def getSampleType (t_start)
 
def getSubRunType (sam, filename)
 

Variables

 parser
 
 action
 
 help
 
 default
 
 choices
 
 type
 
 args = parser.parse_args()
 
string rep = ''
 
 sam = swc.SAMWebClient("nova")
 
string dim_run_range = '(run_number >= {} and run_number <={})'
 
string dim_file_name = '(file_name like "%{}%")'
 
string dim_data_tier = '(data_tier {})'
 
string theDIM = dim_run_range+' and '
 
 flist = sam.listFiles(theDIM)
 
 nfile = len(flist)
 
int i = 0
 
 start_type
 
 end_type
 
 isCurrent
 
dictionary mfmetadata
 

Function Documentation

def modify_metadata_with_upmu_sample_type.getSampleType (   t_start)

Definition at line 8 of file modify_metadata_with_upmu_sample_type.py.

References Munits.deg, and makeTrainCVSamples.int.

Referenced by getSubRunType().

8 def getSampleType(t_start):
9  if t_start ==0:
10  return "NULL"
11  deg = ephem.degrees
12  sun = ephem.Sun()
13  nova = ephem.Observer()
14  nova.lat = '48:22.715780'
15  nova.lon = '92:49.876930'
16  nova.date = datetime.datetime.fromtimestamp(
17  int(t_start)).strftime('%Y/%m/%d %H:%M')
18  sun.compute(nova)
19  angle = sun.alt
20  if angle >deg('10'):
21  stype = "Day"
22  elif angle <=deg('10') and angle >deg('-10'):
23  stype="Twilight"
24  elif angle <=deg('-10') and angle > deg('-20'):
25  stype="SignalExtended"
26  else:
27  stype="SignalPrimary"
28  #print "{}\t{}\t{}".format(nova.date, angle, stype)
29  return stype
30 
static constexpr Double_t deg
Definition: Munits.h:165
def modify_metadata_with_upmu_sample_type.getSubRunType (   sam,
  filename 
)

Definition at line 31 of file modify_metadata_with_upmu_sample_type.py.

References novadaq::HexUtils.format(), getSampleType(), and makeTrainCVSamples.int.

31 def getSubRunType(sam, filename):
32  metadata = sam.getMetadata(filename)
33  key_start = "Analysis.UpMuSampleType"
34  key_end = "Analysis.UpMuSampleTypeEnd"
35  if key_start not in metadata or key_end not in metadata:
36  isCurrent = False
37  else:
38  isCurrent = True
39  # Get subrun start/end time, fix them if it's 0.
40  subrun_start = metadata["Online.SubRunStartTime"]
41  subrun_end = metadata["Online.SubRunEndTime"]
42  if subrun_start == 0:
43  if metadata["Online.Subrun"]==0:
44  subrun_start = metadata["Online.RunStartTime"]
45  if subrun_end == 0:
46  try:
47  fsplit = filename.split("_")
48  adjsub="%s_%s_s%d_%s" %(fsplit[0], fsplit[1],
49  int(md["Online.Subrun"])+1 ,fsplit[3])
50  md2=sam.getMetadata(adjsub)
51  subrun_end=md2["Online.SubRunStartTime"]
52  except:
53  print "Error: Retrieving adjacent subrun for run"\
54  " {}, using 3 min duration".format(f)
55  subrun_end = subrun_start+180
56  # Get subrun type (start_type and end_type) based on subrun start/end time.
57  start_type = getSampleType(subrun_start)
58  end_type = getSampleType(subrun_end)
59  # Set the flag if modifying metadata is necessary.
60  if isCurrent and (start_type != metadata[key_start]
61  or end_type != metadata[key_end]):
62  isCurrent = False
63  return (start_type, end_type, isCurrent)
64 
65 
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14

Variable Documentation

modify_metadata_with_upmu_sample_type.action

Definition at line 72 of file modify_metadata_with_upmu_sample_type.py.

modify_metadata_with_upmu_sample_type.args = parser.parse_args()

Definition at line 84 of file modify_metadata_with_upmu_sample_type.py.

modify_metadata_with_upmu_sample_type.choices

Definition at line 75 of file modify_metadata_with_upmu_sample_type.py.

Referenced by stan::math.choose().

modify_metadata_with_upmu_sample_type.default

Definition at line 74 of file modify_metadata_with_upmu_sample_type.py.

string modify_metadata_with_upmu_sample_type.dim_data_tier = '(data_tier {})'

Definition at line 117 of file modify_metadata_with_upmu_sample_type.py.

string modify_metadata_with_upmu_sample_type.dim_file_name = '(file_name like "%{}%")'

Definition at line 115 of file modify_metadata_with_upmu_sample_type.py.

string modify_metadata_with_upmu_sample_type.dim_run_range = '(run_number >= {} and run_number <={})'

Definition at line 111 of file modify_metadata_with_upmu_sample_type.py.

modify_metadata_with_upmu_sample_type.end_type

Definition at line 130 of file modify_metadata_with_upmu_sample_type.py.

modify_metadata_with_upmu_sample_type.flist = sam.listFiles(theDIM)
modify_metadata_with_upmu_sample_type.help

Definition at line 73 of file modify_metadata_with_upmu_sample_type.py.

int modify_metadata_with_upmu_sample_type.i = 0

Definition at line 125 of file modify_metadata_with_upmu_sample_type.py.

modify_metadata_with_upmu_sample_type.isCurrent

Definition at line 130 of file modify_metadata_with_upmu_sample_type.py.

dictionary modify_metadata_with_upmu_sample_type.mfmetadata
Initial value:
1 = {"Analysis.UpMuSampleType": start_type,
2  "Analysis.UpMuSampleTypeEnd": end_type}

Definition at line 131 of file modify_metadata_with_upmu_sample_type.py.

modify_metadata_with_upmu_sample_type.nfile = len(flist)

Definition at line 122 of file modify_metadata_with_upmu_sample_type.py.

modify_metadata_with_upmu_sample_type.parser
Initial value:
1 = argparse.ArgumentParser(
2  prog='modify_metadata_with_upmu_sample_type.py',
3  description="Add UpMu sample type to metadata.",
4  epilog="Questions and Comments to dingpf@fnal.gov")

Definition at line 68 of file modify_metadata_with_upmu_sample_type.py.

modify_metadata_with_upmu_sample_type.rep = ''

Definition at line 87 of file modify_metadata_with_upmu_sample_type.py.

modify_metadata_with_upmu_sample_type.sam = swc.SAMWebClient("nova")

Definition at line 109 of file modify_metadata_with_upmu_sample_type.py.

Referenced by get_eventlist().

modify_metadata_with_upmu_sample_type.start_type

Definition at line 130 of file modify_metadata_with_upmu_sample_type.py.

string modify_metadata_with_upmu_sample_type.theDIM = dim_run_range+' and '

Definition at line 118 of file modify_metadata_with_upmu_sample_type.py.

modify_metadata_with_upmu_sample_type.type

Definition at line 80 of file modify_metadata_with_upmu_sample_type.py.