Пример #1
0
def showDescription(data=None):
    desc = "Program to compute verification scores for weather forecasts. Can be used to compare forecasts from different files. In that case only dates, offsets, and locations that are common to all forecast files are used."
    print textwrap.fill(desc, Common.getTextWidth())
    print ""
    print "usage: verif files -m metric [options]"
    print "       verif --version"
    print ""
    print Common.green("Arguments:")
    print Common.formatArgument(
        "files",
        "One or more verification files in NetCDF or text format (see 'File Formats' below)."
    )
    print Common.formatArgument(
        "-m metric", "Which verification metric to use? See 'Metrics' below.")
    print Common.formatArgument("--version", "What version of verif is this?")
    print ""
    print Common.green("Options:")
    print "Note: vectors can be entered using commas, or MATLAB syntax (i.e 3:5 is 3,4,5 and 3:2:7 is 3,5,7)"
    #print Common.formatArgument("","For vector options, the following are supported:")
    #print Common.formatArgument("","  start:end       e.g. 3:5 gives 3, 4, 5")
    #print Common.formatArgument("","  start:inc:end   e.g. 3:2:7 gives 3, 5, 7")
    #print Common.formatArgument("","  vector1,vector2 e.g. 3:5,1:2 gives 3, 4, 5, 1, 2")
    # Dimensions
    print Common.green("  Dimensions and subset:")
    print Common.formatArgument(
        "-d dates",
        "A vector of dates in YYYYMMDD format, e.g.  20130101:20130201.")
    print Common.formatArgument(
        "-l locations", "Limit the verification to these location IDs.")
    print Common.formatArgument(
        "-llrange range",
        "Limit the verification to locations within minlon,maxlon,minlat,maxlat."
    )
    print Common.formatArgument(
        "-o offsets", "Limit the verification to these offsets (in hours).")
    print Common.formatArgument(
        "-r thresholds",
        "Compute scores for these thresholds (only used by some metrics).")
    print Common.formatArgument(
        "-t period",
        "Allow this many days of training, i.e. remove this many days from the beginning of the verification."
    )
    print Common.formatArgument(
        "-x dim",
        "Plot this dimension on the x-axis: date, offset, location, locationId, locationElev, locationLat, locationLon, threshold, or none. Not supported by all metrics. If not specified, then a default is used based on the metric. 'none' collapses all dimensions and computes one value."
    )

    # Data manipulation
    print Common.green("  Data manipulation:")
    print Common.formatArgument(
        "-acc", "Plot accumulated values. Only works for non-derived metrics")
    print Common.formatArgument(
        "-b type",
        "One of 'below', 'within', or 'above'. For threshold plots (ets, hit, within, etc) 'below/above' computes frequency below/above the threshold, and 'within' computes the frequency between consecutive thresholds."
    )
    print Common.formatArgument(
        "-c file",
        "File containing climatology data. Subtract all forecasts and obs with climatology values."
    )
    print Common.formatArgument(
        "-C file",
        "File containing climatology data. Divide all forecasts and obs by climatology values."
    )
    print Common.formatArgument(
        "-ct type",
        "Collapsing type: 'min', 'mean', 'median', 'max', 'std', and 'range'. Some metrics computes a value for each value on the x-axis. Which function should be used to do the collapsing? Default is 'mean'. Only supported by some metrics."
    )
    print Common.formatArgument(
        "-hist",
        "Plot values as histogram. Only works for non-derived metrics")
    print Common.formatArgument(
        "-sort", "Plot values sorted. Only works for non-derived metrics")

    # Plot options
    print Common.green("  Plotting options:")
    print Common.formatArgument(
        "-bot value", "Bottom boundary location for saved figure [range 0-1]")
    print Common.formatArgument(
        "-clim limits", "Force colorbar limits to the two values lower,upper")
    print Common.formatArgument(
        "-dpi value", "Resolution of image in dots per inch (default 100)")
    print Common.formatArgument("-f file", "Save image to this filename")
    print Common.formatArgument(
        "-fs size", "Set figure size width,height (in inches). Default 8x6.")
    print Common.formatArgument(
        "-leg titles",
        "Comma-separated list of legend titles. Use '_' to represent space.")
    print Common.formatArgument("-lw width", "How wide should lines be?")
    print Common.formatArgument("-labfs size", "Font size for axis labels")
    print Common.formatArgument(
        "-left value", "Left boundary location for saved figure [range 0-1]")
    print Common.formatArgument("-legfs size", "Font size for legend")
    print Common.formatArgument("-majlth length", "Length of major tick marks")
    print Common.formatArgument(
        "-majtwid width", "Adjust the thickness of the major tick marks")
    print Common.formatArgument("-minlth length", "Length of minor tick marks")
    print Common.formatArgument("-ms size", "How big should markers be?")
    print Common.formatArgument(
        "-nomargin", "Remove margins (whitespace) in the plot not x[i] <= T.")
    print Common.formatArgument(
        "-right value", "Right boundary location for saved figure [range 0-1]")
    print Common.formatArgument("-sp",
                                "Show a line indicating the perfect score")
    print Common.formatArgument("-tickfs size", "Font size for axis ticks")
    print Common.formatArgument("-title text", "Custom title to chart top")
    print Common.formatArgument(
        "-top value", "Top boundary location for saved figure [range 0-1]")
    print Common.formatArgument(
        "-type type", "One of 'plot' (default), 'text', 'map', or 'maprank'.")
    print Common.formatArgument("-xlabel text", "Custom x-axis label")
    print Common.formatArgument(
        "-xlim limits", "Force x-axis limits to the two values lower,upper")
    print Common.formatArgument("-xrot value",
                                "Rotation angle for x-axis labels")
    print Common.formatArgument("-ylabel text", "Custom y-axis label")
    print Common.formatArgument(
        "-ylim limits", "Force y-axis limits to the two values lower,upper")
    print ""
    metrics = Metric.getAllMetrics()
    outputs = Output.getAllOutputs()
    print Common.green("Metrics (-m):")
    metricOutputs = metrics + outputs
    metricOutputs.sort(key=lambda x: x[0].lower(), reverse=False)
    for m in metricOutputs:
        name = m[0].lower()
        desc = m[1].summary()
        if (desc != ""):
            print Common.formatArgument(name, desc)
            #print "   %-14s%s" % (name, textwrap.fill(desc, 80).replace('\n', '\n                 ')),
            #print ""
    if (data != None):
        print ""
        print "  Or one of the following, which plots the raw score from the file:"
        print " ",
        metrics = data.getMetrics()
        for metric in metrics:
            print metric,
    print ""
    print ""
    print Common.green("File formats:")
    print Input.Text.description()
    print Input.Comps.description()
Пример #2
0
def showDescription(data=None):
   desc = "Program to compute verification scores for weather forecasts. Can be used to compare forecasts from different files. In that case only dates, offsets, and locations that are common to all forecast files are used."
   print textwrap.fill(desc, Common.getTextWidth())
   print ""
   print "usage: verif files -m metric [options]"
   print "       verif --version"
   print ""
   print Common.green("Arguments:")
   print Common.formatArgument("files", "One or more verification files in NetCDF or text format (see 'File Formats' below).")
   print Common.formatArgument("-m metric","Which verification metric to use? See 'Metrics' below.")
   print Common.formatArgument("--version","What version of verif is this?")
   print ""
   print Common.green("Options:")
   print "Note: vectors can be entered using commas, or MATLAB syntax (i.e 3:5 is 3,4,5 and 3:2:7 is 3,5,7)"
   #print Common.formatArgument("","For vector options, the following are supported:")
   #print Common.formatArgument("","  start:end       e.g. 3:5 gives 3, 4, 5")
   #print Common.formatArgument("","  start:inc:end   e.g. 3:2:7 gives 3, 5, 7")
   #print Common.formatArgument("","  vector1,vector2 e.g. 3:5,1:2 gives 3, 4, 5, 1, 2")
   # Dimensions
   print Common.green("  Dimensions and subset:")
   print Common.formatArgument("-d dates","A vector of dates in YYYYMMDD format, e.g.  20130101:20130201.")
   print Common.formatArgument("-l locations","Limit the verification to these location IDs.")
   print Common.formatArgument("-llrange range","Limit the verification to locations within minlon,maxlon,minlat,maxlat.")
   print Common.formatArgument("-o offsets","Limit the verification to these offsets (in hours).")
   print Common.formatArgument("-r thresholds","Compute scores for these thresholds (only used by some metrics).")
   print Common.formatArgument("-t period","Allow this many days of training, i.e. remove this many days from the beginning of the verification.")
   print Common.formatArgument("-x dim","Plot this dimension on the x-axis: date, offset, location, locationId, locationElev, locationLat, locationLon, threshold, or none. Not supported by all metrics. If not specified, then a default is used based on the metric. 'none' collapses all dimensions and computes one value.")

   # Data manipulation
   print Common.green("  Data manipulation:")
   print Common.formatArgument("-acc","Plot accumulated values. Only works for non-derived metrics")
   print Common.formatArgument("-b type","One of 'below', 'within', or 'above'. For threshold plots (ets, hit, within, etc) 'below/above' computes frequency below/above the threshold, and 'within' computes the frequency between consecutive thresholds.")
   print Common.formatArgument("-c file","File containing climatology data. Subtract all forecasts and obs with climatology values.")
   print Common.formatArgument("-C file","File containing climatology data. Divide all forecasts and obs by climatology values.")
   print Common.formatArgument("-ct type","Collapsing type: 'min', 'mean', 'median', 'max', 'std', and 'range'. Some metrics computes a value for each value on the x-axis. Which function should be used to do the collapsing? Default is 'mean'. Only supported by some metrics.")
   print Common.formatArgument("-hist","Plot values as histogram. Only works for non-derived metrics")
   print Common.formatArgument("-sort","Plot values sorted. Only works for non-derived metrics")

   # Plot options
   print Common.green("  Plotting options:")
   print Common.formatArgument("-bot value","Bottom boundary location for saved figure [range 0-1]")
   print Common.formatArgument("-clim limits","Force colorbar limits to the two values lower,upper")
   print Common.formatArgument("-dpi value","Resolution of image in dots per inch (default 100)")
   print Common.formatArgument("-f file","Save image to this filename")
   print Common.formatArgument("-fs size","Set figure size width,height (in inches). Default 8x6.")
   print Common.formatArgument("-leg titles","Comma-separated list of legend titles. Use '_' to represent space.")
   print Common.formatArgument("-lw width","How wide should lines be?")
   print Common.formatArgument("-labfs size","Font size for axis labels")
   print Common.formatArgument("-left value","Left boundary location for saved figure [range 0-1]")
   print Common.formatArgument("-legfs size","Font size for legend")
   print Common.formatArgument("-majlth length","Length of major tick marks")
   print Common.formatArgument("-majtwid width","Adjust the thickness of the major tick marks")
   print Common.formatArgument("-minlth length","Length of minor tick marks")
   print Common.formatArgument("-ms size","How big should markers be?")
   print Common.formatArgument("-nomargin","Remove margins (whitespace) in the plot not x[i] <= T.")
   print Common.formatArgument("-right value","Right boundary location for saved figure [range 0-1]")
   print Common.formatArgument("-sp","Show a line indicating the perfect score")
   print Common.formatArgument("-tickfs size","Font size for axis ticks")
   print Common.formatArgument("-title text","Custom title to chart top")
   print Common.formatArgument("-top value","Top boundary location for saved figure [range 0-1]")
   print Common.formatArgument("-type type","One of 'plot' (default), 'text', 'map', or 'maprank'.")
   print Common.formatArgument("-xlabel text","Custom x-axis label")
   print Common.formatArgument("-xlim limits","Force x-axis limits to the two values lower,upper")
   print Common.formatArgument("-xrot value","Rotation angle for x-axis labels")
   print Common.formatArgument("-ylabel text","Custom y-axis label")
   print Common.formatArgument("-ylim limits","Force y-axis limits to the two values lower,upper")
   print ""
   metrics = Metric.getAllMetrics()
   outputs = Output.getAllOutputs()
   print Common.green("Metrics (-m):")
   metricOutputs = metrics + outputs
   metricOutputs.sort(key=lambda x: x[0].lower(), reverse=False)
   for m in metricOutputs:
      name = m[0].lower()
      desc = m[1].summary()
      if(desc != ""):
         print Common.formatArgument(name, desc)
         #print "   %-14s%s" % (name, textwrap.fill(desc, 80).replace('\n', '\n                 ')),
         #print ""
   if(data is not None):
      print ""
      print "  Or one of the following, which plots the raw score from the file:"
      print " ",
      metrics = data.getMetrics()
      for metric in metrics:
         print metric,
   print ""
   print ""
   print Common.green("File formats:")
   print Input.Text.description()
   print Input.Comps.description()