code: def modflow_hydmod_to_instruction_file(hydmod_file):
      
  
      hydmod_df, hydmod_outfile = modflow_read_hydmod_file(hydmod_file)
  
  
      hydmod_df.loc[:,"ins_line"] = hydmod_df.obsnme.apply(lambda x:"l1 w !{0:s}!".format(x))
  
      ins_file = hydmod_outfile + ".ins"
  
      with open(ins_file, 'w') as f_ins:
          f_ins.write("pif ~\nl1\n")
          f_ins.write(hydmod_df.loc[:,["ins_line"]].to_string(col_space=0,
                                                       columns=["ins_line"],
                                                       header=False,
                                                       index=False,
                                                       formatters=[SFMT]) + '\n')
      hydmod_df.loc[:,"weight"] = 1.0
      hydmod_df.loc[:,"obgnme"] = "obgnme"
  
      try:
          os.system("inschek {0}.ins {0}".format(hydmod_outfile))
      except:
          print("error running inschek")
  
      obs_obf = hydmod_outfile + ".obf"
      if os.path.exists(obs_obf):
          df = pd.read_csv(obs_obf,delim_whitespace=True,header=None,names=["obsnme","obsval"])
          df.loc[:,"obgnme"] = df.obsnme.apply(lambda x: x[:-9])
          df.to_csv("_setup_"+os.path.split(hydmod_outfile)[-1]+'.csv',index=False)
          df.index = df.obsnme
          return df
  
  
      return hydmod_df
docs: write an instruction file for a modflow hydmod file
  
      Parameters
      ----------
      hydmod_file : str
          modflow hydmod file
  
  
      Returns
      -------
      df : pandas.DataFrame
          pandas DataFrame with control file observation information
  
      Note
      ----
      calls modflow_read_hydmod_file()