USGS Patched ref2sac Version 20170314 Larry Baker baker@usgs.gov March 15, 2017 Usage: ref2sac [ -h | --help ] ref2sac [ -v | --verbose ] [ -f | --flat ] --inDir input_directory --outDir output_directory [ --chnDef channel_def_file ] -h or --help Prints usage message -v or --verbose Prints the name of the file it is working on Prints a line for each packet, ala RT_SAC Summarizes the traces in each data file -f or --flat Writes SAC files in a flattened file structure in the --outDir directory Otherwise (the previous behavior), writes SAC files in ID/Date if no --chnDef (SCNL) mapping, else Network.Station/Date if --chnDef mapping Names the SAC files as RefTekID_Stream_Channel_Year_Day_Time.R.SAC if no --chnDef (SCNL) mapping (R indicates raw data, i.e., no quality review) Otherwise, names the SAC files as Year.Day.Hour.Minute.Second.Network.Station.Location.Channel.R.SAC if --chnDef (SCNL) mapping (R indicates raw data) --inDir Directory containing the Ref Tek raw data files --outDir Top-level directory for the SAC files --chnDef XML SCNL channel mappings Change Log 20170314 ------------------- Fixed sequence point warning in ezxml.c. Fixed memory overflow in when no. of points in data packet header does not match no. returned from Steim decompression in data_rt130.c. Added guards for memory overflow for all data formats in data_rt130.c. Added warnings for too few data points in file, too many data points in file, and corrupted Steim decompression in data_rt130.c. Preserve partial file playback for warnings in data_rt130.c. Added enums for detailed failures and warnings in ref2sac.h. Used detailed enums for failures and warnings in data_entry.c and data_rt130.c. Added more detailed message text for failures and warnings in main.c. Changed files makefile ref2sac.h data_entry.c data_rt130.c ezxml.c main.c Change Log 20160414 ------------------- Fixed bug introduced in 20141107 for Steim-2 compressed data. Eliminated u_char and u_int in steim.h; use C99 uint8_t and uint32_t instead. Use C99 int8_t, uint8_t, int32_t, and uint32_t where data size and signedness matters. (The C standard does not require that a char is 8 bits.) Use void * for opaque data in reverse memcpy routines in steim.c. Add sanity checks for size in reverse memcpy routines in steim.c. Define function prototypes in the correct header files. Remove duplicate function prototypes. Remove #include . Added ref2sac version identification to stdout. Changed files pql_data_struct.h ref2sac.h reftek.h steim.h data_rt125.c data_rt125a.c data_rt130.c steim.c steim2.c ezxml.c Change Log 20141107 ------------------- data_endian.c Removed unused assembly language. data_entry.c Simplify freeing traceInfo components; reinitialize pointers. Fix access to uninitialized ret variable which caused traces to be erroneously skipped. Print type of file found if --verbose option. data_rt125.c Use C99 stdint.h data types. Use arithmetic shift instead of conditional to sign extend 24-bit data. Correctly identify data packets without the extended header. data_rt125a.c Use C99 stdint.h data types. Use arithmetic shift instead of conditional to sign extend 24-bit data. data_rt130.c Use C99 stdint.h data types. Add position (lat, lon, alt) and units to event header info. Add units to channel info. Use %0X instead of %0x and ASCII upcase for sensor ID. Add a number of static functions to safely decode ASCII data packet fields. (They are not C strings.) Safely access ASCII data packet fields. (They are not C strings.) Print packet fields ala RT_SAC for --verbose option. Replace endian() with testByteOrder() Correctly convert uncompressed data. Simplify data conversions. ezxml.c Fix assignments/comparison of (signed) -1 with (unsigned) size_t len. file.c Change free() to g_free() for glib strings. Remove extra space at the end of the file. include/pql_data_struct.h Use C99 stdint.h data types. Add lat, lon, elev, and units to event header info. include/ref2sac.h Remove MY_BIG_ENDIAN (it is in myendian.h). Add function prototypes for swap_2byte() and swap_4byte(). include/reftek.h Add position (lat, lon, alt) and units to event header info. Add units to channel info. Pass data packet as u_char * to Steim decoders. Remove endian(); use testByteOrder() instead. include/sac.h Fix spacing and remove trailing blanks. include/steim.h Remove endian(). include/tapestrc.h Use C99 stdint.h data types. Add typedef's for Ref Tek data packet field data types (all 8 bits): RT_ASCII, RT_BCD, RT_HEX, RT_BINARY, RT_RESERVED. Updated packet definitions from REF TEK PASSCAL Recording Format, Document no. 96493-00-AW, Rev K, 7/29/2014, Trimble Navigation Ltd. main.c Add --flat option to create SAC files in a single directory. Add --verbose option to enable progress messages and data packet decoding. Print usage() and exit for an unrecognized command line option. Clarify some error messages. Call chdir() to restore current directory before checking --outDir. (Relative --outDir path failed.) Use SAC for the SAC file name suffix (like rdseed). The --flat option names SAC files following the rdseed convention when SEED SCNLs are found (--chnDef); otherwise, the Ref Tek ID is prefixed to the SAC file name. Incude stla, stlo, stel in SAC file. Change idep from IVEL to IUNKN in SAC file. (Data are counts, not engineering units.) Blank pad SAC ASCII header fields. (They are not C strings.) Safely access SAC ASCII header fields. Print file names and trace info if --verbose option. Free all dynamically allocated storage (i.e., linked lists). Change free() to g_free() for glib strings. makefile Add pkg-config, -O2 -Wextra to CFLAGS. Add pkg-config to LDFLAGS. reftek_utils.c Simplify time code conversion in ascii2bin(). Safely acess Ref Tek ASCII time code fields. steim.c Remove endian(). Pass data packet as u_char * to steim1(). Remove unused code. steim2.c Pass data packet as u_char * to steim2().