def pysiral_l2proc_time_range_job(args): """ This is a Level-2 Processor job for a given time range """ # Get start time of processor run t0 = time.clock() # Get the product definition product_def = Level2ProductDefinition(args.run_tag, args.l2_settings_file) mission_id = product_def.l2def.mission.id hemisphere = product_def.l2def.hemisphere # Specifically add an output handler product_def.add_output_definition( args.l2_output, overwrite_protection=args.overwrite_protection) # --- Get the period for the Level-2 Processor --- # Evaluate the input arguments period = DatePeriod(args.start, args.stop) # Clip the time range to the valid time range of the target platform period = period.intersect(psrlcfg.get_platform_period(mission_id)) # The Level-2 processor operates in monthly iterations # -> Break down the full period into monthly segments and # filter specific month that should not be processed period_segments = period.get_segments("month", crop_to_period=True) if args.exclude_month is not None: period_segments.filter_month(args.exclude_month) # Prepare DataHandler l1b_data_handler = DefaultL1bDataHandler(mission_id, hemisphere, version=args.l1b_version) # Processor Initialization l2proc = Level2Processor(product_def) # Now loop over the month for time_range in period_segments: # Do some extra logging l2proc.log.info("Processing period: %s" % time_range.label) # Product Data Management if args.remove_old: for output_handler in product_def.output_handler: output_handler.remove_old(time_range) # Get input files l1b_files = l1b_data_handler.get_files_from_time_range(time_range) l2proc.log.info("Found %g files in %s" % (len(l1b_files), l1b_data_handler.last_directory)) # Process the orbits l2proc.process_l1b_files(l1b_files) # All done t1 = time.clock() seconds = int(t1 - t0) l2proc.log.info("Run completed in %s" % str(timedelta(seconds=seconds)))
def pysiral_l2proc_time_range_job(args): """ This is a Level-2 Processor job for a given time range """ # Get start time of processor run t0 = time.clock() # Get the product definition product_def = Level2ProductDefinition(args.run_tag, args.l2_settings_file) mission_id = product_def.l2def.mission.id hemisphere = product_def.l2def.hemisphere # Specifically add an output handler product_def.add_output_definition( args.l2_output, overwrite_protection=args.overwrite_protection) # Break down the time range in individual month start, stop = args.start, args.stop job = TimeRangeRequest(start, stop, exclude_month=args.exclude_month) job.clip_to_mission(mission_id) job.raise_if_empty() # Prepare DataHandler l1b_data_handler = DefaultL1bDataHandler(mission_id, hemisphere, version=args.l1b_version) # Processor Initialization l2proc = Level2Processor(product_def) # # Loop over iterations (one per month) for time_range in job.iterations: # Do some extra logging l2proc.log.info("Processing period: %s" % time_range.label) # Product Data Management if args.remove_old: for output_handler in product_def.output_handler: output_handler.remove_old(time_range) # Get input files l1b_files = l1b_data_handler.get_files_from_time_range(time_range) l2proc.log.info("Found %g files in %s" % (len(l1b_files), l1b_data_handler.last_directory)) # Process the orbits l2proc.process_l1b_files(l1b_files) # All done t1 = time.clock() seconds = int(t1 - t0) l2proc.log.info("Run completed in %s" % str(timedelta(seconds=seconds)))
def pysiral_l2proc_l1b_predef_job(args): """ A more simple Level-2 job with a predefined list of l1b data files """ # Get start time of processor run t0 = time.clock() # Get the product definition product_def = Level2ProductDefinition(args.run_tag, args.l2_settings_file) # Specifically add an output handler product_def.add_output_definition(args.l2_output, overwrite_protection=args.overwrite_protection) # Processor Initialization l2proc = Level2Processor(product_def) l2proc.process_l1b_files(args.l1b_predef_files) # All done t1 = time.clock() seconds = int(t1-t0) logger.info("Run completed in %s" % str(timedelta(seconds=seconds)))