Commit d3911734 authored by Dario Barghini's avatar Dario Barghini
Browse files

Several modifications to enable NSSM run

parent b57d7b15
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ _device_type = 'SQM_LE' # Device type in the Header
_device_id = _device_type + '-' + _observatory_name # Long Device lame
_device_locationname = 'Pino Torinese/Italy - Astrophysical Observatory of Torino' # Device location in the world
_data_supplier = 'Dario Barghini / INAF - OATo' # Data supplier (contact)
_device_addr = '169.254.156.64' # Default IP address of the ethernet device (if not automatically found)
_device_addr = '169.254.65.200' # Default IP address of the ethernet device (if not automatically found)

'''
----------------
@@ -86,7 +86,7 @@ _mysql_port = None # Port of the MySQL server
DIRECTORY settings
------------------
'''
main_directory = "C:\\sqm\\pysqm_data" # Main directory
main_directory = "C:\\pysqm\\data" # Main directory
monthly_data_directory = main_directory + "\\monthly\\" # Monthly (permanent) data
daily_data_directory = main_directory + "\\daily\\" # Daily (permanent) data
daily_graph_directory = main_directory + "\\daily\\" # Daily (permanent) graph
+17 −13
Original line number Diff line number Diff line
@@ -27,12 +27,13 @@ ____________________________
#import sys

#import pysqm.main as main
from pysqm import main
from pysqm import main as pysqm_main

def main():
    while 1==1:
        # Loop forever to make sure the program does not die.
        try:
        main.loop()
            pysqm_main.loop()
        except Exception as e:
            print('')
            print('FATAL ERROR while running the main loop !!')
@@ -40,3 +41,6 @@ while 1==1:
            print(e)
            print('Trying to restart')
            print('')

if __name__ == "__main__":
    main()
 No newline at end of file
+7 −1
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ for directory in [config.monthly_data_directory,config.daily_data_directory,conf
    if not os.path.exists(directory):
        os.makedirs(directory)


'''
Select the device to be used based on user input
and start the measures
@@ -107,6 +106,7 @@ def loop():
    observ = define_ephem_observatory()
    niter = 0
    old_daily_datafile = ''
    old_yearmonth = ''
    DaytimePrint = True
    print('Starting readings ...')
    while 1<2:
@@ -133,6 +133,12 @@ def loop():
                old_daily_datafile = mydevice.daily_datafile
                niter = 0

            # Create new month directory in daily_data_directory
            if mydevice.yearmonth != old_yearmonth:
                directory = config.daily_data_directory+'/'+mydevice.yearmonth
                if not os.path.exists(directory):
                    os.makedirs(directory)
            
            ''' Get values from the photometer '''
            try:
                timeutc_mean,timelocal_mean,temp_sensor,\
+6 −6
Original line number Diff line number Diff line
@@ -608,7 +608,7 @@ class Plot(object):
        '''
        if np.size(Data.Night)==1:
            self.thegraph_sunalt.text(0.75,1.015,'Moon: %d%s (%d%s)' \
             %(Ephem.moon_phase, "%", Ephem.moon_maxelev*180./np.pi,"$^\mathbf{o}$"),\
             %(Ephem.moon_phase, "%", Ephem.moon_maxelev*180./np.pi,r"$^\mathbf{o}$"),\
             color='#d62728',fontsize='small',fontname='monospace',\
             transform = self.thegraph_sunalt.transAxes)
        '''
@@ -683,7 +683,7 @@ class Plot(object):

        if np.size(Data.Night)==1:
            self.thegraph_time.text(0.75,1.015,'Moon: %d%s (%d%s)' \
             %(Ephem.moon_phase, "%", Ephem.moon_maxelev*180./np.pi,"$^\mathbf{o}$"),\
             %(Ephem.moon_phase, "%", Ephem.moon_maxelev*180./np.pi,r"$^\mathbf{o}$"),\
             color='black',fontsize='small',fontname='monospace',\
             transform = self.thegraph_time.transAxes)

@@ -831,8 +831,8 @@ def make_plot(input_filename=None,send_emails=False,write_stats=False):
        str("%s/%s_%s.png" %(config.current_data_directory,\
            config._device_shorttype,config._observatory_name)),\
        str("%s/%s_120000_%s-%s.png"\
            %(config.daily_graph_directory, str(NSBData.Night).replace('-',''),\
              config._device_shorttype, config._observatory_name))\
            %(config.daily_graph_directory+str(NSBData.Night)[0:7].replace('-',''),\
              str(NSBData.Night).replace('-',''),config._device_shorttype, config._observatory_name))\
    ]

    for output_filename in output_filenames:
+5 −3
Original line number Diff line number Diff line
@@ -184,8 +184,10 @@ class device(observatory):
        date_time_file = self.local_datetime(\
         self.read_datetime())-datetime.timedelta(hours=12)
        date_file = date_time_file.date()
        yearmonth = str(date_file)[0:7]
        yearmonthday = str(date_file)[0:10]
        yearmonth = str(date_file)[0:7].replace('-','')
        yearmonthday = str(date_file)[0:10].replace('-','')
        self.yearmonth = yearmonth
        self.yearmonthday = yearmonthday

        self.monthly_datafile = \
         config.monthly_data_directory+"/"+config._device_shorttype+\
@@ -194,7 +196,7 @@ class device(observatory):
        # config.daily_data_directory+"/"+config._device_shorttype+\
        # "_"+config._observatory_name+"_"+yearmonthday+".dat"
        self.daily_datafile = \
         config.daily_data_directory+"/"+\
         config.daily_data_directory+"/"+yearmonth+"/"+\
         yearmonthday.replace('-','')+'_120000_'+\
         config._device_shorttype+'-'+config._observatory_name+'.dat'
        self.current_datafile = \
Loading