Example #1
0
def profile_error(cubes, axis, mapping, coord):
    for variable in mapping:
        # Extract the plot styles for the variable
        c = mapping[variable]
        # Load the cube
        cube = cubes.extract(variable)[0]
        nice_units(cube, coord)

        # Analysis (exclude first forecast)
        analysis = cube[1:].extract(iris.Constraint(forecast_lead_time=6))

        # 24h lead time (exclude last forecast)
        forecast = cube[:-1].extract(iris.Constraint(forecast_lead_time=30))

        # Take the difference between the 48h forecast and the 24h forecast for
        # the same verification time
        diff = forecast.data - analysis.data
        diff = forecast.copy(data=diff)

        # Take the mean difference
        mean, std_err = second_analysis.extract_statistics(
            diff, 'forecast_index')

        plot.errorbar(mean,
                      mean.coord(coord),
                      xerr=std_err,
                      linestyle=c.linestyle,
                      color=c.color,
                      label=c.symbol)

    return
Example #2
0
def profile_multi(cubes, axis, mapping, coord):
    for variable in mapping:
        # Extract the plot styles for the variable
        c = mapping[variable]
        # Load the cube
        cube = cubes.extract(variable)[0]
        cube = cube.extract(iris.Constraint(forecast_lead_time=24))
        nice_units(cube, coord)

        # Plot tropopause gradient vs lead time
        mean, std_err = second_analysis.extract_statistics(
            cube, 'forecast_index')
        plot.errorbar(mean,
                      mean.coord(coord),
                      xerr=std_err,
                      linestyle=c.linestyle,
                      color=c.color,
                      label=c.symbol)

    return
Example #3
0
def main():
    # Parameters to compare between forecasts
    name = 'Temperature [K]'
    pressure = 500
    path = datadir + 'cirrus/'
    cs = iris.Constraint(
        name=name,
        pressure=pressure,
        forecast_reference_time=(
            lambda cell:
            (PartialDateTime(year=1982) < cell < PartialDateTime(year=1992))))

    # Load full precision reference forecast
    with iris.FUTURE.context(cell_datetime_objects=True):
        fp = iris.load_cube(path + '1982-1991_p52.nc', cs)

        # Compare with reduced precision forecasts
        rp = iris.load(path + '*_10-30.nc', cs)
        rp = rp.concatenate_cube()

    # Calculate the global RMS error at each forecast lead time
    diff = rms_diff(rp, fp)

    # Calculate the mean error as a function of precision and the standard error
    # of the mean for each lead time
    mean = diff.collapsed('forecast_reference_time', MEAN)
    std_dev = diff.collapsed('forecast_reference_time', STD_DEV)
    std_err = (std_dev /
               np.sqrt(len(diff.coord('forecast_reference_time').points)))

    for mean_slice, std_slice in zip(mean.slices(['precision']),
                                     std_err.slices(['precision'])):
        plot.errorbar(mean_slice, yerr=std_slice, marker='x')

    plt.savefig(plotdir + 'average_errors' + '_' + name.split()[0].lower() +
                '_' + str(pressure) + 'hpa.png')
    plt.show()

    return