Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/local/bin/python 

2# encoding: utf-8 

3""" 

4*import the ZTF stream into the marshall* 

5 

6:Author: 

7 David Young 

8""" 

9import sys 

10import os 

11os.environ['TERM'] = 'vt100' 

12from fundamentals import tools 

13from ..data import data as basedata 

14from astrocalc.times import now 

15from fundamentals.mysql import writequery 

16 

17 

18class data(basedata): 

19 """ 

20 *Import the ZTF transient data into the marshall database* 

21 

22 **Key Arguments** 

23 

24 - ``log`` -- logger 

25 - ``dbConn`` -- the marshall database connection 

26 - ``settings`` -- the settings dictionary 

27 

28 

29 **Usage** 

30 

31 To setup your logger, settings and database connections, please use the ``fundamentals`` package (`see tutorial here <http://fundamentals.readthedocs.io/en/latest/#tutorial>`_).  

32 

33 To initiate a data object, use the following: 

34 

35 ```python 

36 from marshallEngine.feeders.ztf.data import data 

37 ingester = data( 

38 log=log, 

39 settings=settings, 

40 dbConn=dbConn 

41 ).ingest(withinLastDays=withInLastDay)  

42 ``` 

43 

44 """ 

45 # Initialisation 

46 

47 def __init__( 

48 self, 

49 log, 

50 dbConn, 

51 settings=False, 

52 ): 

53 self.log = log 

54 log.debug("instansiating a new 'data' object") 

55 self.settings = settings 

56 self.dbConn = dbConn 

57 

58 self.fsTableName = "fs_ztf" 

59 self.survey = "ZTF" 

60 

61 # xt-self-arg-tmpx 

62 

63 return None 

64 

65 def ingest( 

66 self, 

67 withinLastDays): 

68 """*Ingest the data into the marshall feeder survey table* 

69 

70 **Key Arguments** 

71 

72 - ``withinLastDays`` -- within the last number of days. *Default: 50* 

73 

74 """ 

75 self.log.debug('starting the ``ingest`` method') 

76 

77 allLists = [] 

78 

79 sqlQuery = """call update_fs_ztf()""" % locals() 

80 writequery( 

81 log=self.log, 

82 sqlQuery=sqlQuery, 

83 dbConn=self.dbConn 

84 ) 

85 

86 # self._import_to_feeder_survey_table() 

87 self.insert_into_transientBucket() 

88 

89 # CLEAN UP TASKS TO MAKE THE TICKET UPDATE 

90 self.clean_up() 

91 

92 self.log.debug('completed the ``ingest`` method') 

93 return None