41#define PI 3.1415926535897932
42#define D2R (PI / 180.0)
54 while (fgets(buff,
sizeof(buff), fp)) {
55 if (!strncmp(buff,
"$$", 2)) {
58 if (sscanf(buff,
"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", v, v + 1, v + 2, v + 3, v + 4, v + 5, v + 6,
59 v + 7, v + 8, v + 9, v + 10) < 11) {
62 for (i = 0; i < 11; i++) {
63 odisp[n + i * 6] = v[i];
90extern int readelmask(
const char* file, int16_t* elmask) {
92 double az[360], el[360], mask = 0.0;
96 trace(NULL, 3,
"readelmask: file=%s\n", file);
98 for (i = 0; i < 360; i++) {
101 if (!(fp = fopen(file,
"r"))) {
102 fprintf(stderr,
"elevation mask file open error : %s\n", file);
105 while (fgets(buff,
sizeof(buff), fp) && n < 360) {
106 if ((p = strchr(buff,
'%'))) {
109 if ((p = strchr(buff,
'#'))) {
112 if (sscanf(buff,
"%lf %lf", az + n, el + n) == 2) {
118 for (i = 0; i < 360; i++) {
119 if (j < n && i >= (
int)az[j]) {
122 elmask[i] = (int16_t)(mask / 0.1);
135extern void readpos(
const char* file,
const char* rcv,
double* pos) {
136 static double poss[2048][3];
137 static char stas[2048][16];
139 int i, j, len, np = 0;
140 char buff[256], str[256];
142 trace(NULL, 3,
"readpos: file=%s\n", file);
144 if (!(fp = fopen(file,
"r"))) {
145 fprintf(stderr,
"reference position file open error : %s\n", file);
148 while (np < 2048 && fgets(buff,
sizeof(buff), fp)) {
149 if (buff[0] ==
'%' || buff[0] ==
'#') {
152 if (sscanf(buff,
"%lf %lf %lf %s", &poss[np][0], &poss[np][1], &poss[np][2], str) < 4) {
155 sprintf(
stas[np++],
"%.15s", str);
158 len = (int)strlen(rcv);
159 for (i = 0; i < np; i++) {
160 if (strncmp(
stas[i], rcv, len)) {
163 for (j = 0; j < 3; j++) {
170 pos[0] = pos[1] = pos[2] = 0.0;
179extern int readblq(
const char* file,
const char* sta,
double* odisp) {
181 char buff[256], staname[32] =
"", name[32], *p;
184 sscanf(sta,
"%16s", staname);
185 for (p = staname; (*p = (char)toupper((
int)(*p))); p++) {
189 if (!(fp = fopen(file,
"r"))) {
190 trace(NULL, 2,
"blq file open error: file=%s\n", file);
193 while (fgets(buff,
sizeof(buff), fp)) {
194 if (!strncmp(buff,
"$$", 2) || strlen(buff) < 2) {
198 if (sscanf(buff + 2,
"%16s", name) < 1) {
201 for (p = name; (*p = (char)toupper((
int)(*p))); p++) {
204 if (strcmp(name, staname)) {
215 trace(NULL, 2,
"no otl parameters: sta=%s file=%s\n", sta, file);
static sta_t stas[MAXRCV]
int readelmask(const char *file, int16_t *elmask)
Read elevation mask file.
void readpos(const char *file, const char *rcv, double *pos)
Read station positions from file.
int readblq(const char *file, const char *sta, double *odisp)
Read BLQ ocean tide loading parameters.
int readblqrecord(FILE *fp, double *odisp)
Read a single BLQ record (6 lines x 11 values).
MRTKLIB Station Module — Site environment parameter I/O.
void trace(mrtk_ctx_t *ctx, int level, const char *format,...)
Output trace message.
MRTKLIB Trace Module — debug trace and logging functions.