Scan Archive

One advantage of MSNoise is its ability to be used as an automated monitoring tool. In order to run every night on the data acquired during the previous day, MSNoise needs to check the data archive for new or modified files.

Those files could have been acquired during the last day, but be data of a previously offline station and contain useful information for, say, a month ago. The time to search for is defined in the config from the ‘crondays’ value. For convenience, this parameter can be temporarily redefined on the command line using the –crondays option of the scan_archive sub-command. In both cases, it can be a float designating a number of days in the past, or a string designating a number of weeks, days, and/or hours in the format ‘Xw Xd Xh’ (each group being optional, as well as the separating blanks).

The scan_archive script inspects the modified time attribute (‘mtime’) of files in the archives to locate new or modified files. Once located, they are inserted (if new) or updated (if modified) in the data availability table.

To run the code on two Process, execute the following in console:

$ msnoise -t 2 scan_archive

Compulsory Special case: first run

This script is the same as for the routine, but one has to pass the –init option. The scan_archive will scan all files in the data folders, regardless of their modification time.

$ msnoise -t 2 scan_archive --init

This will scan the data_archive folder the configured stations and will insert all files found in the data_availability table in the database. As usual, calling the script with a –help argument will show its usage.

Expert (lazy) mode:

Sometimes, you only want to scan a few files and run MSNoise on them. To do this simply run:

$ msnoise scan_archive --path /path/to/where/files/are --init

and MSNoise will read anything ObsPy can (provided the files have a proper header (network code, station code and channel code). Then, once done, simply run the “populate from DataAvailability” procedure.

This command can also scan folders recursively:

$ msnoise scan_archive --path /path/to/archive --recursively --init