code: def replace_model(refwcs, newcoeffs):
      
      print('WARNING:')
      print('    Replacing existing distortion model with one')
      print('    not necessarily matched to the observation!')
      # create linear version of WCS to be updated by new model
      wcslin = stwcs.distortion.utils.undistortWCS(refwcs)
      outwcs = refwcs.deepcopy()
      outwcs.wcs.cd = wcslin.wcs.cd
      outwcs.wcs.set()
      outwcs.setOrient()
      outwcs.setPscale()
      # add new model to updated WCS object
      add_model(outwcs,newcoeffs)
      # Update CD matrix with new model
      apply_model(outwcs)
  
      # replace original input WCS with newly updated WCS
      refwcs = outwcs.deepcopy()
docs: Replace the distortion model in a current WCS with a new model
          Start by creating linear WCS, then run