Skip to contents

This generic function creates a SeaSondeRCS object either from a file path or directly from a list containing header and data. When x is a character string, the function determines the file type (either "CS", "CSSY" or "CSSW") by analyzing the spectra file and reads it using the appropriate reading function. If specs_path is not provided (or set to rlang::zap()), the default YAML specifications path corresponding to the detected file type is used.

Usage

seasonder_createSeaSondeRCS(x, specs_path = NULL, ...)

Arguments

x

Either a character string specifying the path to the SeaSonde CS file or a list containing header and data.

specs_path

A character string specifying the path to the YAML specifications for the CS file. Used only if x is a character string.

...

Additional parameters passed to the underlying functions.

Value

A SeaSondeRCS object.

Details

For character inputs, the function first checks if the specified file exists. It then determines the file type using seasonder_find_spectra_file_type. If the specs_path parameter is not provided or is set to rlang::zap(), the default specifications file path is obtained using seasonder_defaultSpecsFilePath based on the detected file type. The file is then read using the appropriate reading function:

  • seasonder_readSeaSondeCSFile for CS files.

  • seasonder_readSeaSondeRCSSYFile for CSSY files.

  • seasonder_readSeaSondeRCSSWFile for CSSW files.

For list inputs, the SeaSondeRCS object is created directly from the provided header and data. Additionally, a processing step is appended to the object using seasonder_setSeaSondeRCS_ProcessingSteps with a creation step text that indicates the source.

Examples

# Creating a SeaSondeRCS object from a list
cs_file <- system.file("css_data/CSS_TORA_24_04_04_0700.cs", package = "SeaSondeR")
specs_path <- seasonder_defaultSpecsFilePath("CS")
temp_obj <- seasonder_readSeaSondeCSFile(cs_file, specs_path)
cs_list <- list(header = temp_obj$header, data = temp_obj$data)
rcs_object <- seasonder_createSeaSondeRCS(cs_list)

# Creating a SeaSondeRCS object from a file path using default YAML specifications
rcs_object <- seasonder_createSeaSondeRCS(system.file("css_data/CSS_TORA_24_04_04_0700.cs", 
package = "SeaSondeR"))

# Creating a SeaSondeRCS object from a file path with a specified YAML specifications file
rcs_object <- seasonder_createSeaSondeRCS(
  system.file("css_data/CSS_TORA_24_04_04_0700.cs", package = "SeaSondeR"),
  specs_path = seasonder_defaultSpecsFilePath("CS")
)