st_greater_than = 260
                st_less_than = None
                algo = eustace.surface_temperature.ST_ALGORITHM.IST
            elif algorithm == eustace.surface_temperature.ST_ALGORITHM.IST + "_GT_240_LT_260":
                st_less_than = 260
                st_greater_than = 240
                algo = eustace.surface_temperature.ST_ALGORITHM.IST
            else:
                st_less_than = None
                st_greater_than = None
                algo = algorithm

            y_array = np.array([row[0] for row in db.get_perturbed_values(swath_variables=None,
                                                                          lat_less_than=args["--lat-lt"],
                                                                          lat_greater_than=args["--lat-gt"],
                                                                          tb_11_minus_tb_12_limit=args["--t11-t12-limit"],
                                                                          st_less_than=st_less_than,
                                                                          st_greater_than=st_greater_than,
                                                                          algorithm=algo,
                                                                          limit=limit)])
            LOG.debug("Took: %s" % (str(datetime.datetime.now() - t)))

            # Number of samples - total.
            LOG.info("Number of samples: %i." %(len(y_array)))

            # Make sure that there are no nan in the array.
            y_array_is_not_nan = y_array[~np.isnan(y_array)]

            # Number of samples.
            LOG.info("Number of samples without NaN: %i." %(len(y_array_is_not_nan)))

            LOG.debug("Calculating the average.")
Ejemplo n.º 2
0
        x_arrays[variable]=[]

    random.seed(1)

    LOG.debug("Get the values from the database.")
    t = datetime.datetime.now()
    with eustace.db.Db(args["<database-filename>"]) as db:
        # Where sql used for the title in the plots.
        where_sql = db.build_where_sql(lat_less_than=args["--lat-lt"],
                                       lat_greater_than=args["--lat-gt"],
                                       tb_11_minus_tb_12_limit=args["--t11-t12-limit"],
                                       algorithm=args["--algorithm"])
        # Get the values.
        for row in db.get_perturbed_values(variable_names,
                                           lat_less_than=args["--lat-lt"],
                                           lat_greater_than=args["--lat-gt"],
                                           tb_11_minus_tb_12_limit=args["--t11-t12-limit"],
                                           algorithm=args["--algorithm"],
                                           limit=limit):
            y_array.append(row[0])
            for i in range(len(variable_names)):
                if row[i + 1] == None:
                    x_arrays[variable_names[i]].append(np.NaN)
                else:
                    x_arrays[variable_names[i]].append(row[i + 1])
    LOG.debug("Took: %s" % (str(datetime.datetime.now() - t)))

    LOG.info("%i samples" %(len(y_array)))
    y_array = np.array(y_array)

    y_array_is_not_nan = y_array[~np.isnan(y_array)]
    average_all = np.average(y_array_is_not_nan)