Example #1
0
void SaveISISNexus::user() {
  NXmakegroup(handle, "user_1", "NXuser");
  NXopengroup(handle, "user_1", "NXuser");

  saveChar("name", m_isisRaw->user.r_user, 20);
  saveChar("affiliation", m_isisRaw->user.r_instit, 20);

  NXclosegroup(handle); // user_1
}
Example #2
0
void SaveISISNexus::sample() {
  NXmakegroup(handle, "sample", "NXsample");
  NXopengroup(handle, "sample", "NXsample");

  saveChar("name", m_isisRaw->spb.e_name, 40);
  saveFloat("height", &m_isisRaw->spb.e_height, 1);
  saveFloat("width", &m_isisRaw->spb.e_width, 1);
  saveFloat("thickness", &m_isisRaw->spb.e_thick, 1);
  saveString("id", " ");
  float tmp(0.0);
  saveFloat("distance", &tmp, 1);
  std::string shape[] = {"cylinder", "flat plate", "HRPD slab", "unknown"};
  int i = m_isisRaw->spb.e_geom - 1;
  if (i < 0 || i > 3)
    i = 3;
  saveString("shape", shape[i]);
  std::string type[] = {"sample+can", "empty can",      "vanadium", "absorber",
                        "nothing",    "sample, no can", "unknown"};
  i = m_isisRaw->spb.e_type - 1;
  if (i < 0 || i > 6)
    i = 6;
  saveString("type", type[i]);

  NXclosegroup(handle); // sample
}
Example #3
0
QHash<QString, QString> UrlEncode::getConfiguration()
{
    QHash<QString, QString> properties = TransformAbstract::getConfiguration();
    properties.insert(XMLPERCENTCHAR,saveChar(percentSign));
    properties.insert(XMLINCLUDE,QString(include.toBase64()));
    properties.insert(XMLEXCLUDE,QString(exclude.toBase64()));

    return properties;
}
Example #4
0
/** Execute the algorithm. Currently just calls SaveISISNexusProcessed but could
 *  call write other formats if support added
 *
 *  @throw runtime_error Thrown if algorithm cannot execute
 */
void SaveISISNexus::exec() {
  // Retrieve the filename from the properties
  inputFilename = getPropertyValue("InputFileName");

  m_isisRaw = new ISISRAW2;
  rawFile = fopen(inputFilename.c_str(), "rb");
  if (rawFile == nullptr) {
    throw Exception::FileError("Cannot open file ", inputFilename);
  }
  m_isisRaw->ioRAW(rawFile, true);

  nper = m_isisRaw->t_nper; // number of periods
  nsp = m_isisRaw->t_nsp1;  // number of spectra
  ntc = m_isisRaw->t_ntc1;  // number of time channels
  nmon = m_isisRaw->i_mon;  // number of monitors
  ndet = m_isisRaw->i_det;  // number of detectors

  std::string outputFilename = getPropertyValue("OutputFileName");

  NXstatus status;
  float flt;

  status = NXopen(outputFilename.c_str(), NXACC_CREATE5, &handle);
  if (status != NX_OK) {
    throw std::runtime_error("Cannot open file " + outputFilename +
                             " for writing.");
  }
  NXmakegroup(handle, "raw_data_1", "NXentry");
  NXopengroup(handle, "raw_data_1", "NXentry");
  write_isis_vms_compat();
  saveString("beamline", " ");

  flt = static_cast<float>(m_isisRaw->rpb.r_dur); // could be wrong
  saveFloatOpen("collection_time", &flt, 1);
  putAttr("units", "second");
  close();

  saveStringOpen("definition", "TOFRAW");
  putAttr("version", "1.0");
  putAttr("url",
          "http://definition.nexusformat.org/instruments/TOFRAW/?version=1.0");
  close();

  saveStringOpen("definition_local", "ISISTOFRAW");
  putAttr("version", "1.0");
  putAttr("url",
          "http://svn.isis.rl.ac.uk/instruments/ISISTOFRAW/?version=1.0");
  close();

  flt = static_cast<float>(m_isisRaw->rpb.r_dur);
  saveFloatOpen("duration", &flt, 1);
  putAttr("units", "second");
  close();

  start_time_str.assign(m_isisRaw->hdr.hd_date, m_isisRaw->hdr.hd_date + 12);
  toISO8601(start_time_str);
  start_time_str += 'T';
  start_time_str +=
      std::string(m_isisRaw->hdr.hd_time, m_isisRaw->hdr.hd_time + 8);
  saveCharOpen("start_time", &start_time_str[0], 19);
  putAttr("units", "ISO8601");
  close();

  std::string str;
  str.assign(m_isisRaw->rpb.r_enddate, m_isisRaw->rpb.r_enddate + 12);
  toISO8601(str);
  str += 'T';
  str += std::string(m_isisRaw->rpb.r_endtime, m_isisRaw->rpb.r_endtime + 8);
  saveCharOpen("end_time", &str[0], 19);
  putAttr("units", "ISO8601");
  close();

  saveChar("title", m_isisRaw->r_title, 80);
  saveInt("good_frames", &m_isisRaw->rpb.r_goodfrm);

  std::string experiment_identifier = std::to_string(m_isisRaw->rpb.r_prop);
  saveChar("experiment_identifier", &experiment_identifier[0],
           static_cast<int>(experiment_identifier.size()));
  int tmp_int(0);
  saveInt("measurement_first_run", &tmp_int);
  saveString("measurement_id", " ");
  saveString("measurement_label", " ");
  saveString("measurement_subid", " ");
  saveString("measurement_type", " ");

  saveCharOpen("name", &m_isisRaw->i_inst, 8);
  putAttr("short_name", m_isisRaw->hdr.inst_abrv, 3);
  close();

  logNotes();

  saveString("program_name", "isisicp");

  saveFloatOpen("proton_charge", &m_isisRaw->rpb.r_gd_prtn_chrg, 1);
  putAttr("units", "uamp.hour");
  close();

  saveFloatOpen("proton_charge_raw", &m_isisRaw->rpb.r_tot_prtn_chrg, 1);
  putAttr("units", "uamp.hour");
  close();

  saveInt("raw_frames", &m_isisRaw->rpb.r_rawfrm);

  run_cycle();

  saveInt("run_number", &m_isisRaw->r_number);

  // script_name
  // seci_config

  instrument();

  make_detector_1_link();

  write_monitors();

  user();

  sample();

  runlog();

  selog();

  NXclosegroup(handle); // raw_data_1
  status = NXclose(&handle);

  delete m_isisRaw;
}
Example #5
0
/// Write isis_vms_compat
void SaveISISNexus::write_isis_vms_compat() {
  NXmakegroup(handle, "isis_vms_compat", "IXvms");
  NXopengroup(handle, "isis_vms_compat", "IXvms");
  int ndet = m_isisRaw->i_det;
  int nmon = m_isisRaw->i_mon;

  saveInt("ADD", &m_isisRaw->add, 9);
  saveInt("CODE", m_isisRaw->code, ndet);
  saveInt("CRAT", m_isisRaw->crat, ndet);

  write_rpb();
  write_spb();
  write_vpb();
  saveInt("DAEP", &m_isisRaw->daep, 64);
  saveInt("DELT", m_isisRaw->delt, ndet);
  saveInt("FORM", &m_isisRaw->data_format);
  saveChar("HDR", &m_isisRaw->hdr, 80);
  saveFloat("LEN2", m_isisRaw->len2, ndet);
  saveInt("MDET", m_isisRaw->mdet, nmon);
  saveInt("MODN", m_isisRaw->modn, ndet);
  saveInt("MONP", m_isisRaw->monp, nmon);
  saveInt("MPOS", m_isisRaw->mpos, ndet);
  saveChar("NAME", m_isisRaw->i_inst, 8);
  saveInt("NDET", &ndet);
  saveInt("NFPP", &m_isisRaw->t_nfpp);
  saveInt("NMON", &nmon);
  saveInt("NPER", &m_isisRaw->t_nper);
  saveInt("NSER", &m_isisRaw->e_nse);
  saveInt("NSP1", &m_isisRaw->t_nsp1);
  saveInt("NTC1", &m_isisRaw->t_ntc1);
  saveInt("NTRG", &m_isisRaw->t_ntrg);
  saveInt("NUSE", &m_isisRaw->i_use);
  saveInt("PMAP", &m_isisRaw->t_pmap, 256);
  saveInt("PRE1", &m_isisRaw->t_pre1);
  saveInt("RUN", &m_isisRaw->r_number);
  saveInt("SPEC", m_isisRaw->spec, ndet);
  saveInt("TCM1", &m_isisRaw->t_tcm1);
  saveFloat("TCP1", m_isisRaw->t_tcp1, 20);
  saveInt("TIMR", m_isisRaw->timr, ndet);
  saveChar("TITL", m_isisRaw->r_title, 80);
  saveFloat("TTHE", m_isisRaw->tthe, ndet);
  saveInt("UDET", m_isisRaw->udet, ndet);
  saveInt("ULEN", &m_isisRaw->u_len);
  std::string user_info(160, ' ');
  if (m_isisRaw->u_len > 0) {
    std::copy(reinterpret_cast<char *>(&m_isisRaw->user),
              reinterpret_cast<char *>(&m_isisRaw->user) + m_isisRaw->u_len,
              user_info.begin());
  }
  saveString("USER", user_info);
  saveInt("VER1", &m_isisRaw->frmt_ver_no);
  saveInt("VER2", &m_isisRaw->ver2);
  saveInt("VER3", &m_isisRaw->ver3);
  saveInt("VER4", &m_isisRaw->ver4);
  saveInt("VER5", &m_isisRaw->ver5);
  saveInt("VER6", &m_isisRaw->ver6);
  saveInt("VER7", &m_isisRaw->ver7);
  saveInt("VER8", &m_isisRaw->ver8);
  int tmp_int(0);
  saveInt("VER9", &tmp_int);

  int n = m_isisRaw->logsect.nlines;
  log_notes.resize(n);
  for (int i = 0; i < n; ++i) {
    log_notes[i].assign(m_isisRaw->logsect.lines[i].data,
                        m_isisRaw->logsect.lines[i].len);
  }
  int ll = saveStringVectorOpen("NOTE", log_notes);
  saveInt("NTNL", &n);
  saveInt("NTLL", &ll);

  NXclosegroup(handle); // isis_vms_compat
}
Example #6
0
/**
  * Save a string in a dataset.
  * @param name :: Name of the data set
  * @param str :: The vector to save
  */
void SaveISISNexus::saveString(const char *name, const std::string &str) {
  if (str.empty())
    return;
  std::string buff(str);
  saveChar(name, &buff[0], static_cast<int>(buff.size()));
}
Example #7
0
QHash<QString, QString> NumberToChar::getConfiguration()
{
    QHash<QString, QString> properties = TransformAbstract::getConfiguration();
    properties.insert(XMLSEPARATOR,saveChar(separator));
    return properties;
}