Skip to contents

This method creates a SeaSondeRCS object by reading a file from the specified file path. It verifies the file's existence, determines the file type ("CS", "CSSY" or "CSSW") using seasonder_find_spectra_file_type, and then reads the file using the appropriate function. If specs_path is not provided (or is set to rlang::zap()), the default YAML specifications file path is retrieved using seasonder_defaultSpecsFilePath based on the detected file type.

Usage

# S3 method for class 'character'
seasonder_createSeaSondeRCS(x, specs_path = rlang::zap(), endian = "big", ...)

Arguments

x

A character string specifying the path to the SeaSonde CS file.

specs_path

A character string specifying the path to the YAML specifications for the CS file. If not provided or set to rlang::zap(), the default specifications path for the detected file type is used.

endian

A character string indicating the byte order. Options are "big" (default) or "little".

...

Additional parameters passed to new_SeaSondeRCS for creating the object.

Value

A SeaSondeRCS object.

Details

The function performs the following steps:

  1. Checks if the file specified by x exists; if not, it aborts with an error.

  2. Determines the file type using seasonder_find_spectra_file_type.

  3. If specs_path is not provided or is set to rlang::zap(), retrieves the default YAML specifications path using seasonder_defaultSpecsFilePath based on the detected file type.

  4. Reads the file using the appropriate function:

    • seasonder_readSeaSondeCSFile for CS files.

    • seasonder_readSeaSondeRCSSYFile for CSSY files.

    • seasonder_readSeaSondeRCSSWFile for CSSW files.

  5. Creates a SeaSondeRCS object using new_SeaSondeRCS with the header and data obtained from the file.

  6. Appends a processing step indicating the creation source via seasonder_setSeaSondeRCS_ProcessingSteps with a creation step text generated by SeaSondeRCS_creation_step_text(x).

Examples

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

# Create a SeaSondeRCS object from a file 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")
)