code: def recast(args):
      
  
      import yaml
      from numpy import arange
      from sick.models import Model
      
      # Load in the original model.
      model = Model(args.original_model_filename)
  
      # Load in the channel information
      with open(args.channel_description_filename, "r") as fp:
          channel_description = yaml.load(fp)
  
      # Put the channel description into the format we need.
      channels = {}
      required_keys = ("wavelength_start", "wavelength_end", "wavelength_step")
      for name, descr in channel_description.iteritems():
          # Description must have:
          # wavelength_start, wavelength_end, wavelength_step,
          # optional: resolution.
          missing_keys = set(required_keys).difference(descr)
          if missing_keys:
              raise KeyError("channel {0} is missing the following key(s): {1}"\
                  .format(name, ", ".join(missing_keys)))
  
          if descr["wavelength_start"] >= descr["wavelength_end"]:
              raise ValueError("wavelength start value for channel {0} is greater"
                  " than or equal to the end value ({1} >= {2})".format(
                      name, descr["wavelength_start"], descr["wavelength_end"]))
          if 0 >= descr["wavelength_step"]:
              raise ValueError("wavelength step for channel {} must be a positive"
                  " value".format(name))
  
          wavelengths = arange(descr["wavelength_start"], descr["wavelength_end"],
              descr["wavelength_step"])
  
          if 2 > wavelengths.size:
              raise ValueError("number of wavelength points requested for channel"
                  "{} is less than two".format(name))
  
          resolution = descr.get("resolution", float("inf"))
          channels[name] = (wavelengths, resolution)
  
      return model.cast(args.model_name, channels, output_dir=args.output_dir,
          clobber=args.clobber, __progressbar=True)
docs: Create a model by recasting an existing model.