Mantid
Loading...
Searching...
No Matches
Static Public Member Functions | Static Private Member Functions | List of all members
Mantid::API::InstrumentFileFinder Class Reference

#include <InstrumentFileFinder.h>

Static Public Member Functions

static std::string getInstrumentFilename (const std::string &instrumentName, const std::string &date="")
 Get the IDF using the instrument name and date.
 
static std::string getParameterFilename (const std::string &instrumentName, const std::string &date="", const std::string &dirHint="")
 Get the Parameter file using the instrument name and date, optionally searching dirHint first before the standard instrument directories.
 
static std::string getParameterPath (const std::string &instName, const std::string &dirHint="")
 Search instrument directories for Parameter file, return full path name if found, else "".
 
static std::vector< std::string > getResourceFilenames (const std::string &prefix, const std::vector< std::string > &fileFormats, const std::vector< std::string > &directoryNames, const std::string &date)
 Utility to retrieve a resource file (IDF, Parameters, ..)
 
static void getValidFromTo (const std::string &IDFfilename, std::string &outValidFrom, std::string &outValidTo)
 Utility to retrieve the validity dates for the given IDF.
 

Static Private Member Functions

static std::string getFilenameByInstrumentDateAndSearchTerm (const std::string &instrumentName, const std::string &date, const std::string &searchTerm, const std::vector< std::string > &fileFormats, const std::string &dirHint="")
 This method returns a file name which finds a file which contains the given instrument name + search term and is valid at the given date.
 
static const std::string getNormalisedDate (const std::string &date)
 If date with only YYYY - MM - DD was provided (no time component), append midnight so DateAndTime can parse it.
 
static std::string lookupIPF (const std::string &dir, std::string filename)
 

Detailed Description

Definition at line 16 of file InstrumentFileFinder.h.

Member Function Documentation

◆ getFilenameByInstrumentDateAndSearchTerm()

std::string Mantid::API::InstrumentFileFinder::getFilenameByInstrumentDateAndSearchTerm ( const std::string &  instrumentName,
const std::string &  date,
const std::string &  searchTerm,
const std::vector< std::string > &  fileFormats,
const std::string &  dirHint = "" 
)
staticprivate

This method returns a file name which finds a file which contains the given instrument name + search term and is valid at the given date.

The search will look for filenames which start with InstrumentName + SearchTerm and match the provided file formats.

If several files are found with valid names and valid date ranges, the file with the most recent "valid-from" date is selected. If files are found with valid names but which do not match the date, the file with the most recent "valid-from" date is selected.

If no file is found to have a valid name, an empty string is returned.

Parameters
instrumentName:: Instrument name e.g. GEM, TOPAS or BIOSANS
date:: ISO 8601 date
searchTerm:: Snippet expected as part of filename eg. "_Definition" or "_Parameters"
fileFormats:: Acceptable file extensions
dirHint:: Any non-standard directory that should be search alongside the Instrument Directories
Returns
full path of the file or empty string

Definition at line 88 of file InstrumentFileFinder.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, and getResourceFilenames().

Referenced by getInstrumentFilename(), and getParameterFilename().

◆ getInstrumentFilename()

std::string Mantid::API::InstrumentFileFinder::getInstrumentFilename ( const std::string &  instrumentName,
const std::string &  date = "" 
)
static

Get the IDF using the instrument name and date.

A given instrument may have multiple definition files associated with it.

This method returns a file name which identifies a given instrument definition for a given instrument. The instrument geometry can be loaded from either a ".xml" file (old-style IDF) or a ".hdf5/.nxs" file (new-style nexus).

The search will look for filenames which start with InstrumentName + _Definition and match the above extensions.

If several files are found with valid names and valid date ranges, the file with the most recent "valid-from" date is selected. If files are found with valid names but which do not match the date, the file with the most recent "valid-from" date is selected.

If no file is found to have a valid name, an empty string is returned.

Parameters
instrumentName:: Instrument name e.g. GEM, TOPAS or BIOSANS
date:: ISO 8601 date
Returns
full path of instrument geometry file

Definition at line 153 of file InstrumentFileFinder.cpp.

References getFilenameByInstrumentDateAndSearchTerm().

Referenced by Mantid::DataHandling::LoadDetectorsGroupingFile::exec(), Mantid::DataHandling::LoadInstrument::exec(), Mantid::DataHandling::LoadNXSPE::exec(), Mantid::DataHandling::SNSAppendGeometryToNexus::exec(), export_ExperimentInfo(), exportInstrumentFileFinder(), Mantid::DataHandling::NXcanSAS::InstrumentNameInfo::getIdfFromFile(), getInstrumentFilenameWarn(), Mantid::Algorithms::VesuvioL1ThetaResolution::loadInstrument(), Mantid::DataHandling::LoadEventNexus::runLoadInstrument(), MantidQt::MantidWidgets::SlitCalculator::setInstrument(), and Mantid::API::ExperimentInfo::setInstumentFromXML().

◆ getNormalisedDate()

const std::string Mantid::API::InstrumentFileFinder::getNormalisedDate ( const std::string &  date)
staticprivate

If date with only YYYY - MM - DD was provided (no time component), append midnight so DateAndTime can parse it.

Otherwise just return back the same date string

Parameters
date:: string of date read from file

Definition at line 65 of file InstrumentFileFinder.cpp.

Referenced by getResourceFilenames().

◆ getParameterFilename()

std::string Mantid::API::InstrumentFileFinder::getParameterFilename ( const std::string &  instrumentName,
const std::string &  date = "",
const std::string &  dirHint = "" 
)
static

Get the Parameter file using the instrument name and date, optionally searching dirHint first before the standard instrument directories.

A given instrument may also have multiple parameter files associated with it.

This method returns a file name which identifies a parameter file associated with the given date for a given instrument. The parameter can be loaded from either a ".xml" file (old-style IDF) or a ".hdf5/.nxs" file (new-style nexus).

The search will look for filenames which start with InstrumentName + _Parameters and match the above extensions.

If several files are found with valid names and valid date ranges, the file with the most recent "valid-from" date is selected. If files are found with valid names but which do not match the date, the file with the most recent "valid-from" date is selected.

If no file is found to have a valid name, an empty string is returned.

Parameters
instrumentName:: Instrument name e.g. GEM, TOPAS or BIOSANS
date:: ISO 8601 date
dirHint:: Any non-standard directory that should be search alongside the Instrument Directories
Returns
full path of instrument geometry file

Definition at line 176 of file InstrumentFileFinder.cpp.

References getFilenameByInstrumentDateAndSearchTerm().

Referenced by exportInstrumentFileFinder(), Mantid::DataHandling::LoadIDFFromNexus::loadParameterFile(), and Mantid::DataHandling::LoadInstrument::runLoadParameterFile().

◆ getParameterPath()

std::string Mantid::API::InstrumentFileFinder::getParameterPath ( const std::string &  instName,
const std::string &  dirHint = "" 
)
static

Search instrument directories for Parameter file, return full path name if found, else "".

Search the directory for the Parameter IDF file and return full path name if found, else return "".

Definition at line 184 of file InstrumentFileFinder.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, Mantid::Kernel::ConfigServiceImpl::getInstrumentDirectories(), and lookupIPF().

Referenced by exportInstrumentFileFinder().

◆ getResourceFilenames()

std::vector< std::string > Mantid::API::InstrumentFileFinder::getResourceFilenames ( const std::string &  prefix,
const std::vector< std::string > &  fileFormats,
const std::vector< std::string > &  directoryNames,
const std::string &  date 
)
static

Utility to retrieve a resource file (IDF, Parameters, ..)

Compile a list of files in compliance with name pattern-matching, file format, and date-stamp constraints.

Ideally, the valid-from and valid-to of any valid file should encapsulate argument date. If this is not possible, then the file with the most recent valid-from stamp is selected.

Parameters
prefix:: the name of a valid file must begin with this pattern
fileFormats:: the extension of a valid file must be one of these formats
directoryNames:: search only in these directories
date:: the valid-from and valid-to of a valid file should encapsulate this date
Returns
list of absolute paths for each valid file

Definition at line 264 of file InstrumentFileFinder.cpp.

References Mantid::Geometry::d, Mantid::Kernel::Logger::debug(), Mantid::API::g_log, getNormalisedDate(), getResourceFilenames(), getValidFromTo(), and Mantid::Kernel::Logger::warning().

Referenced by getFilenameByInstrumentDateAndSearchTerm(), getResourceFilenames(), and getResourceFilenames().

◆ getValidFromTo()

void Mantid::API::InstrumentFileFinder::getValidFromTo ( const std::string &  IDFfilename,
std::string &  outValidFrom,
std::string &  outValidTo 
)
static

Utility to retrieve the validity dates for the given IDF.

Return from an IDF the values of the valid-from and valid-to attributes.

Parameters
IDFfilename:: Full path of an IDF
[out]outValidFrom:: Used to return valid-from date
[out]outValidTo:: Used to return valid-to date

Definition at line 394 of file InstrumentFileFinder.cpp.

Referenced by getResourceFilenames(), and Mantid::DataHandling::LoadInstrument::runLoadParameterFile().

◆ lookupIPF()

std::string Mantid::API::InstrumentFileFinder::lookupIPF ( const std::string &  dir,
std::string  filename 
)
staticprivate

Definition at line 215 of file InstrumentFileFinder.cpp.

Referenced by getParameterPath().


The documentation for this class was generated from the following files: