if os.path.exists(ndfdStaticFilepath): response = 'no response given yet' while not response in ('yes', 'no'): print "\nstatic file for %s region already exists, do you want to replace it ?" % region response = raw_input("Enter 'yes' or 'no' : ") if response in ('y', 'yes'): os.remove(ndfdStaticFilepath) print ndfdStaticFilepath, 'exists :', os.path.exists( ndfdStaticFilepath) break elif response in ('n', 'no'): print 'Execution ending, will not replace', ndfdStaticFilepath exit() ndfd_factory = NDFDProjectFactory() ndfd_factory.useDirpathsForMode('dev') bbox = N.array( [float(coord) for coord in ndfd_factory.config[region_path].split(',')]) bbox_lats = bbox[N.where(bbox > 0.)] bbox_lons = bbox[N.where(bbox < 0.)] if verbose: print 'region lats =', bbox_lats print 'region lons =', bbox_lons print '\nreading lat, lon and elevation from ACIS CONUS file' static_factory = AcisProjectFactory(CONFIG) static_factory.useDirpathsForMode('dev') static_reader = static_factory.staticFileReader('acis5k', 'conus') acis_lats = static_reader.get2DSlice('lat', bbox[0], bbox[2], bbox[1], bbox[3]) acis_lons = static_reader.get2DSlice('lon', bbox[0], bbox[2], bbox[1], bbox[3])
var_name_map = {'maxt':'Maximum temperature', 'mint':'Minimum temperature'} today = datetime.date.today() num_args = len(args) if num_args == 0: target_date = today elif num_args == 1: target_date = datetime.date(today.year, today.month, int(args[0])) elif num_args == 2: target_date = datetime.date(today.year, int(args[0]), int(args[1])) elif num_args == 3: target_date = datetime.date(int(args[0]), int(args[1]), int(args[2])) factory = NDFDProjectFactory() if dev_mode: factory.useDirpathsForMode('dev') ndfd = factory.getSourceConfig('ndfd') region = factory.getRegionConfig(region_key) source = factory.getSourceConfig(source_key) print 'updating % source file with NDFD forecast' % source.tag # need indexes from static file for source reader = factory.getStaticFileReader(source, region) source_shape = reader.getDatasetShape('ndfd.x_indexes') ndfd_indexes = [ reader.getData('ndfd.y_indexes').flatten(), reader.getData('ndfd.x_indexes').flatten() ] reader.close() del reader reader = factory.getSourceFileReader(source, target_date.year, region, 'temps') last_obs_date = \