code: def check_crs(crs):
      
      import pyproj
      if isinstance(crs, pyproj.Proj):
          out = crs
      elif isinstance(crs, dict) or isinstance(crs, basestring):
          try:
              out = pyproj.Proj(crs)
          except RuntimeError:
              try:
                  out = pyproj.Proj(init=crs)
              except RuntimeError:
                  out = None
      else:
          out = None
      return out
docs: Checks if the crs represents a valid grid, projection or ESPG string.
  
      (Code copied from https://github.com/fmaussion/salem)
  
      Examples
      --------
      >>> p = check_crs('+units=m +init=epsg:26915')
      >>> p.srs
      '+units=m +init=epsg:26915 '
      >>> p = check_crs('wrong')
      >>> p is None
      True
      Returns
      -------
      A valid crs if possible, otherwise None