meteortools.fileformats.imoWorkingShowerList
1# 2# python module to read the IMO Working Shower short List 3# 4# Copyright (C) 2018-2023 Mark McIntyre 5 6import xmltodict 7import datetime 8import os 9import numpy as np 10import copy 11 12try: 13 from ..utils import jd2Date, sollon2jd 14except Exception: 15 from meteortools.utils import jd2Date, sollon2jd 16 17# imported from $SRC/share 18try: 19 from majorminor import majorlist, minorlist 20except Exception: 21 majorlist = ['QUA', 'LYR', 'ETA', 'CAP', 'SDA', 'PER', 'AUR', 'ORI', 'NTA', 'STA', 'LEO', 'GEM', 'URS'] 22 minorlist = ['SPE','OCT','DRA','EGE','MON','HYD','COM','NOO'] 23 24 25class IMOshowerList: 26 """ 27 Class that loads and parses the IMO Working Shower list, or if needed, the unconfirmed list. 28 Not all known showers are in the IMO working list. If a shower is not in the Working List then 29 this library will reference the full shower list curated by Peter Jenniskens which contains 30 debated and unconfirmed showers. 31 32 These list are updated whenever the library version is bumped, but if you want to override the files, define an 33 environment variable DATADIR and place your own copies of the files at $DATADIR/share. See the share submodule 34 for more information. 35 36 """ 37 def __init__(self, fname=None, fullstreamname=None): 38 if fname is None: 39 datadir = os.getenv('DATADIR', default='/home/ec2-user/prod/data') 40 fname = os.path.join(datadir, 'share', 'IMO_Working_Meteor_Shower_List.xml') 41 if not os.path.isfile(fname): 42 datadir=os.path.split(os.path.abspath(__file__))[0] 43 fname = os.path.join(datadir, '..', 'share', 'IMO_Working_Meteor_Shower_List.xml') 44 45 tmplist = xmltodict.parse(open(fname, 'rb').read()) 46 self.showerlist = tmplist['meteor_shower_list']['shower'] 47 if fullstreamname is None: 48 fullstreamname = os.path.join(datadir, 'share', 'streamfulldata.npy') 49 if not os.path.isfile(fullstreamname): 50 datadir=os.path.split(os.path.abspath(__file__))[0] 51 fullstreamname = os.path.join(datadir, '..', 'share', 'streamfulldata.npy') 52 self.fullstreamdata = np.load(fullstreamname) 53 #print('initialised') 54 55 56 def getShowerByCode(self, iaucode, useFull=False): 57 ds = {'@id':None, 'IAU_code':None,'start':None, 'end':None, 58 'peak':None, 'r':None, 'name':None, 'V':None, 'ZHR':None, 'RA':None, 'DE':None, 'pksollon': None} 59 ds2 = {'@id':None, 'IAU_code':None,'start':None, 'end':None, 60 'peak':None, 'r':None, 'name':None, 'V':None, 'ZHR':None, 'RA':None, 'DE':None, 'pksollon': None} 61 for shower in self.showerlist: 62 if shower['IAU_code'] == iaucode: 63 ds = shower 64 if ds['@id'] is None: 65 ds['@id'] = -1 66 pksollong = -1 67 #print(ds) 68 subset = self.fullstreamdata[np.where(self.fullstreamdata[:,3]==iaucode)] 69 if subset is not None: 70 mtch = [sh for sh in subset if int(sh[6]) > -1] 71 if len(mtch) > 0: 72 ds2 = copy.deepcopy(ds) 73 ds2['IAU_code'] = mtch[-1][3].strip() 74 ds2['name'] = mtch[-1][4].strip() 75 ds2['V'] = mtch[-1][12] 76 ds2['@id'] = mtch[-1][1] 77 ds2['RA'] = mtch[-1][8] 78 ds2['DE'] = mtch[-1][9] 79 80 pksollong = float(mtch[-1][7]) 81 dt = datetime.datetime.now() 82 yr = dt.year 83 mth = dt.month 84 jd = sollon2jd(yr, mth, pksollong) 85 pkdt = jd2Date(jd, dt_obj=True) 86 ds2['peak'] = pkdt.strftime('%h %d') 87 # start/end pop idx, ZHR not available in the IAU data 88 ds2['start'] = (pkdt + datetime.timedelta(days=-2)).strftime('%h %d') 89 ds2['end'] = (pkdt + datetime.timedelta(days=2)).strftime('%h %d') 90 ds2['pksollon'] = pksollong 91 #print(ds2) 92 else: 93 # okay so its poor quality but lets try it anyway 94 mtch = subset 95 ds2 = copy.deepcopy(ds) 96 ds2['IAU_code'] = mtch[-1][3].strip() 97 ds2['name'] = mtch[-1][4].strip() 98 ds2['V'] = mtch[-1][12] 99 ds2['@id'] = mtch[-1][1] 100 ds2['RA'] = mtch[-1][8] 101 ds2['DE'] = mtch[-1][9] 102 103 pksollong = float(mtch[-1][7]) 104 dt = datetime.datetime.now() 105 yr = dt.year 106 mth = dt.month 107 jd = sollon2jd(yr, mth, pksollong) 108 pkdt = jd2Date(jd, dt_obj=True) 109 ds2['peak'] = pkdt.strftime('%h %d') 110 # start/end pop idx, ZHR not available in the IAU data 111 ds2['start'] = (pkdt + datetime.timedelta(days=-2)).strftime('%h %d') 112 ds2['end'] = (pkdt + datetime.timedelta(days=2)).strftime('%h %d') 113 ds2['pksollon'] = pksollong 114 if useFull is False: 115 if 'pksollon' not in ds: 116 ds['pksollon'] = ds2['pksollon'] 117 elif ds['pksollon'] is None: 118 ds['pksollon'] = ds2['pksollon'] 119 if ds['peak'] is None: 120 ds['peak'] = ds2['peak'] 121 ds['@id'] = ds2['@id'] 122 return ds 123 else: 124 ds2['ZHR'] = ds['ZHR'] 125 ds2['r'] = ds['r'] 126 return ds2 127 128 def getStart(self, iaucode, currdt=None): 129 shower = self.getShowerByCode(iaucode) 130 if currdt is None: 131 now = datetime.datetime.today().year 132 mth = datetime.datetime.today().month 133 else: 134 now = datetime.datetime.strptime(str(currdt), '%Y%m%d') 135 mth = now.month 136 now = now.year 137 if shower['start'] is not None: 138 startdate = datetime.datetime.strptime(shower['start'], '%b %d') 139 else: 140 startdate = datetime.datetime.strptime(shower['peak'], '%b %d') + datetime.timedelta(days=-3) 141 if iaucode == 'QUA' and mth !=12: 142 # quadrantids straddle yearend 143 now = now - 1 144 startdate = startdate.replace(year=now) 145 return startdate 146 147 def getEnd(self, iaucode, currdt=None): 148 shower = self.getShowerByCode(iaucode) 149 if currdt is None: 150 now = datetime.datetime.today().year 151 mth = datetime.datetime.today().month 152 else: 153 now = datetime.datetime.strptime(str(currdt), '%Y%m%d') 154 mth = now.month 155 now = now.year 156 #print(shower) 157 if shower['end'] is not None: 158 enddate = datetime.datetime.strptime(shower['end'], '%b %d') 159 else: 160 enddate = datetime.datetime.strptime(shower['peak'], '%b %d') + datetime.timedelta(days=3) 161 if iaucode == 'QUA' and mth == 12: 162 # quadrantids straddle yearend 163 now = now + 1 164 enddate = enddate.replace(year=now) 165 return enddate 166 167 def getPeak(self, iaucode, currdt=None): 168 shower = self.getShowerByCode(iaucode) 169 if currdt is None: 170 now = datetime.datetime.today().year 171 mth = datetime.datetime.today().month 172 else: 173 now = datetime.datetime.strptime(str(currdt), '%Y%m%d') 174 mth = now.month 175 now = now.year 176 enddate = datetime.datetime.strptime(shower['peak'], '%b %d') 177 if iaucode == 'QUA' and mth == 12: 178 # quadrantids straddle yearend 179 now = now + 1 180 enddate = enddate.replace(year=now) 181 return enddate 182 183 def getRvalue(self, iaucode): 184 shower = self.getShowerByCode(iaucode) 185 return shower['r'] 186 187 def getName(self, iaucode): 188 shower = self.getShowerByCode(iaucode) 189 return shower['name'] 190 191 def getVelocity(self, iaucode): 192 shower = self.getShowerByCode(iaucode) 193 return shower['V'] 194 195 def getZHR(self, iaucode): 196 shower = self.getShowerByCode(iaucode) 197 zhr = shower['ZHR'] 198 if zhr is None: 199 return -1 200 else: 201 return int(zhr) 202 203 def getRaDec(self, iaucode): 204 shower = self.getShowerByCode(iaucode) 205 return float(shower['RA']), float(shower['DE']) 206 207 def getActiveShowers(self, datetotest, majorOnly=False, inclMinor=False): 208 activelist = [] 209 for shower in self.showerlist: 210 shwname = shower['IAU_code'] 211 if shwname == 'ANT': #skip the anthelion source, its not a real shower 212 continue 213 start = self.getStart(shwname, datetotest.strftime('%Y%m%d')) 214 #print(shwname, start,shower) 215 end = self.getEnd(shwname, datetotest.strftime('%Y%m%d')) + datetime.timedelta(days=3) 216 if datetotest > start and datetotest < end: 217 if majorOnly is False or (majorOnly is True and shwname in majorlist): 218 activelist.append(shwname) 219 elif inclMinor is True and shwname in minorlist: 220 activelist.append(shwname) 221 return activelist 222 223 def getMajorShowers(self, includeSpo=False, stringFmt=False): 224 majlist = majorlist 225 if includeSpo is True: 226 majlist.append('spo') 227 if stringFmt is True: 228 tmplist = '' 229 for shwr in majlist: 230 tmplist = tmplist + shwr + ' ' 231 majlist = tmplist 232 return majlist
class
IMOshowerList:
26class IMOshowerList: 27 """ 28 Class that loads and parses the IMO Working Shower list, or if needed, the unconfirmed list. 29 Not all known showers are in the IMO working list. If a shower is not in the Working List then 30 this library will reference the full shower list curated by Peter Jenniskens which contains 31 debated and unconfirmed showers. 32 33 These list are updated whenever the library version is bumped, but if you want to override the files, define an 34 environment variable DATADIR and place your own copies of the files at $DATADIR/share. See the share submodule 35 for more information. 36 37 """ 38 def __init__(self, fname=None, fullstreamname=None): 39 if fname is None: 40 datadir = os.getenv('DATADIR', default='/home/ec2-user/prod/data') 41 fname = os.path.join(datadir, 'share', 'IMO_Working_Meteor_Shower_List.xml') 42 if not os.path.isfile(fname): 43 datadir=os.path.split(os.path.abspath(__file__))[0] 44 fname = os.path.join(datadir, '..', 'share', 'IMO_Working_Meteor_Shower_List.xml') 45 46 tmplist = xmltodict.parse(open(fname, 'rb').read()) 47 self.showerlist = tmplist['meteor_shower_list']['shower'] 48 if fullstreamname is None: 49 fullstreamname = os.path.join(datadir, 'share', 'streamfulldata.npy') 50 if not os.path.isfile(fullstreamname): 51 datadir=os.path.split(os.path.abspath(__file__))[0] 52 fullstreamname = os.path.join(datadir, '..', 'share', 'streamfulldata.npy') 53 self.fullstreamdata = np.load(fullstreamname) 54 #print('initialised') 55 56 57 def getShowerByCode(self, iaucode, useFull=False): 58 ds = {'@id':None, 'IAU_code':None,'start':None, 'end':None, 59 'peak':None, 'r':None, 'name':None, 'V':None, 'ZHR':None, 'RA':None, 'DE':None, 'pksollon': None} 60 ds2 = {'@id':None, 'IAU_code':None,'start':None, 'end':None, 61 'peak':None, 'r':None, 'name':None, 'V':None, 'ZHR':None, 'RA':None, 'DE':None, 'pksollon': None} 62 for shower in self.showerlist: 63 if shower['IAU_code'] == iaucode: 64 ds = shower 65 if ds['@id'] is None: 66 ds['@id'] = -1 67 pksollong = -1 68 #print(ds) 69 subset = self.fullstreamdata[np.where(self.fullstreamdata[:,3]==iaucode)] 70 if subset is not None: 71 mtch = [sh for sh in subset if int(sh[6]) > -1] 72 if len(mtch) > 0: 73 ds2 = copy.deepcopy(ds) 74 ds2['IAU_code'] = mtch[-1][3].strip() 75 ds2['name'] = mtch[-1][4].strip() 76 ds2['V'] = mtch[-1][12] 77 ds2['@id'] = mtch[-1][1] 78 ds2['RA'] = mtch[-1][8] 79 ds2['DE'] = mtch[-1][9] 80 81 pksollong = float(mtch[-1][7]) 82 dt = datetime.datetime.now() 83 yr = dt.year 84 mth = dt.month 85 jd = sollon2jd(yr, mth, pksollong) 86 pkdt = jd2Date(jd, dt_obj=True) 87 ds2['peak'] = pkdt.strftime('%h %d') 88 # start/end pop idx, ZHR not available in the IAU data 89 ds2['start'] = (pkdt + datetime.timedelta(days=-2)).strftime('%h %d') 90 ds2['end'] = (pkdt + datetime.timedelta(days=2)).strftime('%h %d') 91 ds2['pksollon'] = pksollong 92 #print(ds2) 93 else: 94 # okay so its poor quality but lets try it anyway 95 mtch = subset 96 ds2 = copy.deepcopy(ds) 97 ds2['IAU_code'] = mtch[-1][3].strip() 98 ds2['name'] = mtch[-1][4].strip() 99 ds2['V'] = mtch[-1][12] 100 ds2['@id'] = mtch[-1][1] 101 ds2['RA'] = mtch[-1][8] 102 ds2['DE'] = mtch[-1][9] 103 104 pksollong = float(mtch[-1][7]) 105 dt = datetime.datetime.now() 106 yr = dt.year 107 mth = dt.month 108 jd = sollon2jd(yr, mth, pksollong) 109 pkdt = jd2Date(jd, dt_obj=True) 110 ds2['peak'] = pkdt.strftime('%h %d') 111 # start/end pop idx, ZHR not available in the IAU data 112 ds2['start'] = (pkdt + datetime.timedelta(days=-2)).strftime('%h %d') 113 ds2['end'] = (pkdt + datetime.timedelta(days=2)).strftime('%h %d') 114 ds2['pksollon'] = pksollong 115 if useFull is False: 116 if 'pksollon' not in ds: 117 ds['pksollon'] = ds2['pksollon'] 118 elif ds['pksollon'] is None: 119 ds['pksollon'] = ds2['pksollon'] 120 if ds['peak'] is None: 121 ds['peak'] = ds2['peak'] 122 ds['@id'] = ds2['@id'] 123 return ds 124 else: 125 ds2['ZHR'] = ds['ZHR'] 126 ds2['r'] = ds['r'] 127 return ds2 128 129 def getStart(self, iaucode, currdt=None): 130 shower = self.getShowerByCode(iaucode) 131 if currdt is None: 132 now = datetime.datetime.today().year 133 mth = datetime.datetime.today().month 134 else: 135 now = datetime.datetime.strptime(str(currdt), '%Y%m%d') 136 mth = now.month 137 now = now.year 138 if shower['start'] is not None: 139 startdate = datetime.datetime.strptime(shower['start'], '%b %d') 140 else: 141 startdate = datetime.datetime.strptime(shower['peak'], '%b %d') + datetime.timedelta(days=-3) 142 if iaucode == 'QUA' and mth !=12: 143 # quadrantids straddle yearend 144 now = now - 1 145 startdate = startdate.replace(year=now) 146 return startdate 147 148 def getEnd(self, iaucode, currdt=None): 149 shower = self.getShowerByCode(iaucode) 150 if currdt is None: 151 now = datetime.datetime.today().year 152 mth = datetime.datetime.today().month 153 else: 154 now = datetime.datetime.strptime(str(currdt), '%Y%m%d') 155 mth = now.month 156 now = now.year 157 #print(shower) 158 if shower['end'] is not None: 159 enddate = datetime.datetime.strptime(shower['end'], '%b %d') 160 else: 161 enddate = datetime.datetime.strptime(shower['peak'], '%b %d') + datetime.timedelta(days=3) 162 if iaucode == 'QUA' and mth == 12: 163 # quadrantids straddle yearend 164 now = now + 1 165 enddate = enddate.replace(year=now) 166 return enddate 167 168 def getPeak(self, iaucode, currdt=None): 169 shower = self.getShowerByCode(iaucode) 170 if currdt is None: 171 now = datetime.datetime.today().year 172 mth = datetime.datetime.today().month 173 else: 174 now = datetime.datetime.strptime(str(currdt), '%Y%m%d') 175 mth = now.month 176 now = now.year 177 enddate = datetime.datetime.strptime(shower['peak'], '%b %d') 178 if iaucode == 'QUA' and mth == 12: 179 # quadrantids straddle yearend 180 now = now + 1 181 enddate = enddate.replace(year=now) 182 return enddate 183 184 def getRvalue(self, iaucode): 185 shower = self.getShowerByCode(iaucode) 186 return shower['r'] 187 188 def getName(self, iaucode): 189 shower = self.getShowerByCode(iaucode) 190 return shower['name'] 191 192 def getVelocity(self, iaucode): 193 shower = self.getShowerByCode(iaucode) 194 return shower['V'] 195 196 def getZHR(self, iaucode): 197 shower = self.getShowerByCode(iaucode) 198 zhr = shower['ZHR'] 199 if zhr is None: 200 return -1 201 else: 202 return int(zhr) 203 204 def getRaDec(self, iaucode): 205 shower = self.getShowerByCode(iaucode) 206 return float(shower['RA']), float(shower['DE']) 207 208 def getActiveShowers(self, datetotest, majorOnly=False, inclMinor=False): 209 activelist = [] 210 for shower in self.showerlist: 211 shwname = shower['IAU_code'] 212 if shwname == 'ANT': #skip the anthelion source, its not a real shower 213 continue 214 start = self.getStart(shwname, datetotest.strftime('%Y%m%d')) 215 #print(shwname, start,shower) 216 end = self.getEnd(shwname, datetotest.strftime('%Y%m%d')) + datetime.timedelta(days=3) 217 if datetotest > start and datetotest < end: 218 if majorOnly is False or (majorOnly is True and shwname in majorlist): 219 activelist.append(shwname) 220 elif inclMinor is True and shwname in minorlist: 221 activelist.append(shwname) 222 return activelist 223 224 def getMajorShowers(self, includeSpo=False, stringFmt=False): 225 majlist = majorlist 226 if includeSpo is True: 227 majlist.append('spo') 228 if stringFmt is True: 229 tmplist = '' 230 for shwr in majlist: 231 tmplist = tmplist + shwr + ' ' 232 majlist = tmplist 233 return majlist
Class that loads and parses the IMO Working Shower list, or if needed, the unconfirmed list. Not all known showers are in the IMO working list. If a shower is not in the Working List then this library will reference the full shower list curated by Peter Jenniskens which contains debated and unconfirmed showers.
These list are updated whenever the library version is bumped, but if you want to override the files, define an environment variable DATADIR and place your own copies of the files at $DATADIR/share. See the share submodule for more information.
IMOshowerList(fname=None, fullstreamname=None)
38 def __init__(self, fname=None, fullstreamname=None): 39 if fname is None: 40 datadir = os.getenv('DATADIR', default='/home/ec2-user/prod/data') 41 fname = os.path.join(datadir, 'share', 'IMO_Working_Meteor_Shower_List.xml') 42 if not os.path.isfile(fname): 43 datadir=os.path.split(os.path.abspath(__file__))[0] 44 fname = os.path.join(datadir, '..', 'share', 'IMO_Working_Meteor_Shower_List.xml') 45 46 tmplist = xmltodict.parse(open(fname, 'rb').read()) 47 self.showerlist = tmplist['meteor_shower_list']['shower'] 48 if fullstreamname is None: 49 fullstreamname = os.path.join(datadir, 'share', 'streamfulldata.npy') 50 if not os.path.isfile(fullstreamname): 51 datadir=os.path.split(os.path.abspath(__file__))[0] 52 fullstreamname = os.path.join(datadir, '..', 'share', 'streamfulldata.npy') 53 self.fullstreamdata = np.load(fullstreamname) 54 #print('initialised')
def
getShowerByCode(self, iaucode, useFull=False):
57 def getShowerByCode(self, iaucode, useFull=False): 58 ds = {'@id':None, 'IAU_code':None,'start':None, 'end':None, 59 'peak':None, 'r':None, 'name':None, 'V':None, 'ZHR':None, 'RA':None, 'DE':None, 'pksollon': None} 60 ds2 = {'@id':None, 'IAU_code':None,'start':None, 'end':None, 61 'peak':None, 'r':None, 'name':None, 'V':None, 'ZHR':None, 'RA':None, 'DE':None, 'pksollon': None} 62 for shower in self.showerlist: 63 if shower['IAU_code'] == iaucode: 64 ds = shower 65 if ds['@id'] is None: 66 ds['@id'] = -1 67 pksollong = -1 68 #print(ds) 69 subset = self.fullstreamdata[np.where(self.fullstreamdata[:,3]==iaucode)] 70 if subset is not None: 71 mtch = [sh for sh in subset if int(sh[6]) > -1] 72 if len(mtch) > 0: 73 ds2 = copy.deepcopy(ds) 74 ds2['IAU_code'] = mtch[-1][3].strip() 75 ds2['name'] = mtch[-1][4].strip() 76 ds2['V'] = mtch[-1][12] 77 ds2['@id'] = mtch[-1][1] 78 ds2['RA'] = mtch[-1][8] 79 ds2['DE'] = mtch[-1][9] 80 81 pksollong = float(mtch[-1][7]) 82 dt = datetime.datetime.now() 83 yr = dt.year 84 mth = dt.month 85 jd = sollon2jd(yr, mth, pksollong) 86 pkdt = jd2Date(jd, dt_obj=True) 87 ds2['peak'] = pkdt.strftime('%h %d') 88 # start/end pop idx, ZHR not available in the IAU data 89 ds2['start'] = (pkdt + datetime.timedelta(days=-2)).strftime('%h %d') 90 ds2['end'] = (pkdt + datetime.timedelta(days=2)).strftime('%h %d') 91 ds2['pksollon'] = pksollong 92 #print(ds2) 93 else: 94 # okay so its poor quality but lets try it anyway 95 mtch = subset 96 ds2 = copy.deepcopy(ds) 97 ds2['IAU_code'] = mtch[-1][3].strip() 98 ds2['name'] = mtch[-1][4].strip() 99 ds2['V'] = mtch[-1][12] 100 ds2['@id'] = mtch[-1][1] 101 ds2['RA'] = mtch[-1][8] 102 ds2['DE'] = mtch[-1][9] 103 104 pksollong = float(mtch[-1][7]) 105 dt = datetime.datetime.now() 106 yr = dt.year 107 mth = dt.month 108 jd = sollon2jd(yr, mth, pksollong) 109 pkdt = jd2Date(jd, dt_obj=True) 110 ds2['peak'] = pkdt.strftime('%h %d') 111 # start/end pop idx, ZHR not available in the IAU data 112 ds2['start'] = (pkdt + datetime.timedelta(days=-2)).strftime('%h %d') 113 ds2['end'] = (pkdt + datetime.timedelta(days=2)).strftime('%h %d') 114 ds2['pksollon'] = pksollong 115 if useFull is False: 116 if 'pksollon' not in ds: 117 ds['pksollon'] = ds2['pksollon'] 118 elif ds['pksollon'] is None: 119 ds['pksollon'] = ds2['pksollon'] 120 if ds['peak'] is None: 121 ds['peak'] = ds2['peak'] 122 ds['@id'] = ds2['@id'] 123 return ds 124 else: 125 ds2['ZHR'] = ds['ZHR'] 126 ds2['r'] = ds['r'] 127 return ds2
def
getStart(self, iaucode, currdt=None):
129 def getStart(self, iaucode, currdt=None): 130 shower = self.getShowerByCode(iaucode) 131 if currdt is None: 132 now = datetime.datetime.today().year 133 mth = datetime.datetime.today().month 134 else: 135 now = datetime.datetime.strptime(str(currdt), '%Y%m%d') 136 mth = now.month 137 now = now.year 138 if shower['start'] is not None: 139 startdate = datetime.datetime.strptime(shower['start'], '%b %d') 140 else: 141 startdate = datetime.datetime.strptime(shower['peak'], '%b %d') + datetime.timedelta(days=-3) 142 if iaucode == 'QUA' and mth !=12: 143 # quadrantids straddle yearend 144 now = now - 1 145 startdate = startdate.replace(year=now) 146 return startdate
def
getEnd(self, iaucode, currdt=None):
148 def getEnd(self, iaucode, currdt=None): 149 shower = self.getShowerByCode(iaucode) 150 if currdt is None: 151 now = datetime.datetime.today().year 152 mth = datetime.datetime.today().month 153 else: 154 now = datetime.datetime.strptime(str(currdt), '%Y%m%d') 155 mth = now.month 156 now = now.year 157 #print(shower) 158 if shower['end'] is not None: 159 enddate = datetime.datetime.strptime(shower['end'], '%b %d') 160 else: 161 enddate = datetime.datetime.strptime(shower['peak'], '%b %d') + datetime.timedelta(days=3) 162 if iaucode == 'QUA' and mth == 12: 163 # quadrantids straddle yearend 164 now = now + 1 165 enddate = enddate.replace(year=now) 166 return enddate
def
getPeak(self, iaucode, currdt=None):
168 def getPeak(self, iaucode, currdt=None): 169 shower = self.getShowerByCode(iaucode) 170 if currdt is None: 171 now = datetime.datetime.today().year 172 mth = datetime.datetime.today().month 173 else: 174 now = datetime.datetime.strptime(str(currdt), '%Y%m%d') 175 mth = now.month 176 now = now.year 177 enddate = datetime.datetime.strptime(shower['peak'], '%b %d') 178 if iaucode == 'QUA' and mth == 12: 179 # quadrantids straddle yearend 180 now = now + 1 181 enddate = enddate.replace(year=now) 182 return enddate
def
getActiveShowers(self, datetotest, majorOnly=False, inclMinor=False):
208 def getActiveShowers(self, datetotest, majorOnly=False, inclMinor=False): 209 activelist = [] 210 for shower in self.showerlist: 211 shwname = shower['IAU_code'] 212 if shwname == 'ANT': #skip the anthelion source, its not a real shower 213 continue 214 start = self.getStart(shwname, datetotest.strftime('%Y%m%d')) 215 #print(shwname, start,shower) 216 end = self.getEnd(shwname, datetotest.strftime('%Y%m%d')) + datetime.timedelta(days=3) 217 if datetotest > start and datetotest < end: 218 if majorOnly is False or (majorOnly is True and shwname in majorlist): 219 activelist.append(shwname) 220 elif inclMinor is True and shwname in minorlist: 221 activelist.append(shwname) 222 return activelist