Пример #1
0
                # format contour output file name replacing file extension with .png
                if args.outDir.startswith('/tmp'):
                    outFile = os.path.join(args.outDir, url_src.split('/')[-1].split('.')[0] + '.png')
                else:
                    if "sbd" in url_src:
                        outFile = os.path.join(args.outDir, '/'.join(url_src.split('/')[-3:]).split('.')[0]  + '.png')
                    else:
                        outFile = os.path.join(args.outDir, '/'.join(url_src.split('/')[-2:]).split('.')[0]  + '.png')

                if not os.path.exists(outFile) or args.debug:
                    logger.debug('out file %s', outFile)

                    contour = Contour(startDatetimeUTC, endDatetimeUTC, args.database, [platformName], args.plotgroup,
                                      title, outFile, args.autoscale, args.plotDotParmName, args.booleanPlotGroup)
                    contour.run()

                # Replace netCDF file with png extension and that is the URL of the log
                logUrl = re.sub('\.nc$','.png', url_src)

                # Round the UTC time to the local time and do the query for the 24 hour period the log file falls into
                startDatetime = startDatetimeUTC
                startDateTimeLocal = startDatetime.astimezone(pytz.timezone('America/Los_Angeles'))
                startDateTimeLocal = startDateTimeLocal.replace(hour=0,minute=0,second=0,microsecond=0)
                startDateTimeUTC24hr = startDateTimeLocal.astimezone(pytz.utc)

                endDatetime = startDateTimeLocal
                endDateTimeLocal = endDatetime.replace(hour=23,minute=59,second=0,microsecond=0)
                endDateTimeUTC24hr = endDateTimeLocal.astimezone(pytz.utc)

                outFile = (args.contourDir + '/' + platformName  + '_log_' + startDateTimeUTC24hr.strftime('%Y%m%dT%H%M%S') +
Пример #2
0
    def update(self, start_date, end_date, url_dest):
        try:

            endDatetimeUTC = pytz.utc.localize(end_date)
            startDatetimeUTC = pytz.utc.localize(start_date)

            # format contour output file name replacing file extension with .png
            if "sbd" in url_dest:
                outFile = os.path.join(
                    self.args.outDir,
                    '/'.join(url_dest.split('/')[-3:]).split('.')[0] + '.png')
            else:
                outFile = os.path.join(
                    self.args.outDir,
                    '/'.join(url_dest.split('/')[-2:]).split('.')[0] + '.png')

            title = 'MBARI LRAUV Survey - ' + self.vehicle

            logger.debug('out file {}'.format(outFile))
            contour = Contour(startDatetimeUTC, endDatetimeUTC,
                              self.args.database, [self.vehicle],
                              self.args.plotgroup, title, outFile,
                              self.args.autoscale, self.args.plotDotParmName,
                              self.args.booleanPlotGroup)
            contour.run()

            # Round the UTC time to the local time and do the query for the 24 hour period the log file falls into
            startDatetime = startDatetimeUTC
            startDateTimeLocal = startDatetime.astimezone(
                pytz.timezone('America/Los_Angeles'))
            startDateTimeLocal = startDateTimeLocal.replace(hour=0,
                                                            minute=0,
                                                            second=0,
                                                            microsecond=0)
            startDateTimeUTC24hr = startDateTimeLocal.astimezone(pytz.utc)

            endDatetime = startDateTimeLocal
            endDateTimeLocal = endDatetime.replace(hour=23,
                                                   minute=59,
                                                   second=0,
                                                   microsecond=0)
            endDateTimeUTC24hr = endDateTimeLocal.astimezone(pytz.utc)

            outFile = (self.args.contourDir + '/' + self.vehicle + '_log_' +
                       startDateTimeUTC24hr.strftime('%Y%m%dT%H%M%S') + '_' +
                       endDateTimeUTC24hr.strftime('%Y%m%dT%H%M%S') + '.png')
            url = (self.args.contourUrl + self.vehicle + '_log_' +
                   startDateTimeUTC24hr.strftime('%Y%m%dT%H%M%S') + '_' +
                   endDateTimeUTC24hr.strftime('%Y%m%dT%H%M%S') + '.png')

            logger.debug('out file {} url: {}'.format(outFile, url))
            c = Contour(startDateTimeUTC24hr, endDateTimeUTC24hr,
                        self.args.database, [self.vehicle],
                        self.args.plotgroup, title, outFile,
                        self.args.autoscale, self.args.plotDotParmName,
                        self.args.booleanPlotGroup)
            c.run()

            return True

        except Exception as ex:
            logger.warning(ex)

        return False