Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
saeed
SSHC
Commits
f24c960c
Commit
f24c960c
authored
Mar 29, 2018
by
saeed
Browse files
a bit modification
parent
14bf6ec5
Changes
5
Hide whitespace changes
Inline
Side-by-side
cmpobs.sh
deleted
100755 → 0
View file @
14bf6ec5
gcc
-o
getobs
-std
=
c99
-Wall
-D_GNU_SOURCE
getobs.c
compile.sh
View file @
f24c960c
#!/bin/bash
#!/bin/bash
iobs
=
0
iobs
=
1
isvg
=
1
isvg
=
1
issh
=
1
issh
=
1
...
...
getobs.c
View file @
f24c960c
...
@@ -17,7 +17,7 @@ int main(int argc,char *argv[])
...
@@ -17,7 +17,7 @@ int main(int argc,char *argv[])
int
portno
=
80
;
int
portno
=
80
;
char
*
host
=
"oceandata.smhi.se"
;
char
*
host
=
"oceandata.smhi.se"
;
//char message[] = "GET /ssh/viken/OBSERVATION?from=2017100100&too=2018032000 HTTP/1.1\r\nHost: oceandata.smhi.se\r\nConnection:close\r\n\r\n";
//char message[] = "GET /ssh/viken/OBSERVATION?from=2017100100&too=2018032000 HTTP/1.1\r\nHost: oceandata.smhi.se\r\nConnection:close\r\n\r\n";
char
message
[]
=
"GET /ssh/goteborg/OBSERVATION?from=2017010100&too=2018032
0
00 HTTP/1.0
\r\n
Host: oceandata.smhi.se
\r\n\r\n
"
;
char
message
[]
=
"GET /ssh/goteborg/OBSERVATION?from=2017010100&too=2018032
8
00 HTTP/1.0
\r\n
Host: oceandata.smhi.se
\r\n\r\n
"
;
int
M
=
sizeof
(
message
);
int
M
=
sizeof
(
message
);
//printf("%s\n",message);
//printf("%s\n",message);
//printf("%d\n",M);
//printf("%d\n",M);
...
...
sshval.c
View file @
f24c960c
#include<stdio.h>
#include<stdio.h>
#include<stdlib.h>
#include<stdlib.h>
#include<math.h>
#include<math.h>
#include"s
vgpl
ot.h"
#include"so
r
t.h"
#define LF (64)
#define LF (64)
...
@@ -183,32 +183,10 @@ int main(int argc, char *argv[]){
...
@@ -183,32 +183,10 @@ int main(int argc, char *argv[]){
printf
(
"startdate %d is bigger than enddate %d
\n
"
,
idbeg
,
idend
);
printf
(
"startdate %d is bigger than enddate %d
\n
"
,
idbeg
,
idend
);
return
1
;
return
1
;
}
}
#if 0
for
(
int
i
=
ia
;
i
<=
ib
;
++
i
){
for
(
int
i
=
ia
;
i
<=
ib
;
++
i
){
printf
(
"%d
\t
%f
\n
"
,
icontent
[
i
],
fcontent
[
i
]);
printf
(
"%d
\t
%f
\n
"
,
icontent
[
i
],
fcontent
[
i
]);
}
}
#endif
#if 0
float rmax = sfmax(fcontent,ii+1);
float rmin = sfmin(fcontent,ii+1);
printf("%f\t%f\n",rmin,rmax);
svgmeta svgm;
FILE * filsvg = svg_init(900, 600, 0.0,(float)(ii+1),rmin,rmax,"ssh.html",&svgm);
float *xax = (float *) malloc(sizeof(float) *(ii+1));
for (int i=0; i < (ii+1);++i) xax[i] = (float)(i);
if ( filsvg != NULL){
svg_add(filsvg,xax,fcontent,(ii+1),&svgm);
svg_close(filsvg);
}
#endif
free
(
cfl
);
free
(
cfl
);
free
(
icontent
);
free
(
icontent
);
free
(
fcontent
);
free
(
fcontent
);
...
...
svgtimeseries.c
View file @
f24c960c
#include<stdio.h>
#include<stdio.h>
#include<stdlib.h>
#include<stdlib.h>
#include<math.h>
float
sfmin
(
float
*
y
,
int
N
){
float
sfmin
(
float
*
y
,
int
N
){
float
zm
=
y
[
0
];
float
zm
=
y
[
0
];
for
(
int
i
=
1
;
i
<
N
;
++
i
){
for
(
int
i
=
1
;
i
<
N
;
++
i
){
...
@@ -20,9 +21,8 @@ void create_svg(int, float*, float*);
...
@@ -20,9 +21,8 @@ void create_svg(int, float*, float*);
int
main
(
void
){
int
main
(
void
){
float
height
=
492
.
0
;
float
height
=
600
.
0
;
float
width
=
761
.
0
;
float
width
=
900
.
0
;
FILE
*
fin
=
fopen
(
"barseback_ssh.dat"
,
"r"
);
FILE
*
fin
=
fopen
(
"barseback_ssh.dat"
,
"r"
);
char
c
=
0
;
char
c
=
0
;
...
@@ -46,10 +46,11 @@ int main(void){
...
@@ -46,10 +46,11 @@ int main(void){
}
}
float
vmin
=
sfmin
(
ssh
,
nl
),
vmax
=
sfmax
(
ssh
,
nl
);
float
vmin
=
sfmin
(
ssh
,
nl
),
vmax
=
sfmax
(
ssh
,
nl
);
vmin
-=
(
0
.
25
*
vmin
);
vmax
+=
(
0
.
25
*
vmax
);
height
-=
50
.
0
;
vmin
=
-
0
.
4
;
width
-=
50
.
0
;
vmax
=
1
.
0
;
vmin
+=
(
0
.
2
*
vmin
);
vmax
+=
(
0
.
2
*
vmax
);
printf
(
"min is %f and max is %f
\n
"
,
vmin
,
vmax
);
printf
(
"min is %f and max is %f
\n
"
,
vmin
,
vmax
);
for
(
int
i
=
0
;
i
<
nl
;
++
i
){
for
(
int
i
=
0
;
i
<
nl
;
++
i
){
...
@@ -57,15 +58,40 @@ int main(void){
...
@@ -57,15 +58,40 @@ int main(void){
xa
[
i
]
=
(
width
/
(
xa
[
nl
-
1
]
-
xa
[
0
])
)
*
xa
[
i
]
-
((
width
*
xa
[
0
])
/
(
xa
[
nl
-
1
]
-
xa
[
0
]));
xa
[
i
]
=
(
width
/
(
xa
[
nl
-
1
]
-
xa
[
0
])
)
*
xa
[
i
]
-
((
width
*
xa
[
0
])
/
(
xa
[
nl
-
1
]
-
xa
[
0
]));
}
}
create_svg
(
nl
,
xa
,
ssh
);
#if 0
#if 0
for (int i=0; i < nl; ++i){
for (int i=0; i < nl; ++i){
printf("ssh[%d] %f\n",i,ssh[i]);
printf("ssh[%d] %f\n",i,ssh[i]);
}
}
#endif
create_svg
(
nl
,
xa
,
ssh
);
float PI = 4.0*atan(1.0);
int nx = 100001;
float dx = (2.0*PI)/(nx -1);
float *xx = (float*)malloc(nx *sizeof(float));
float *yy = (float*)malloc(nx *sizeof(float));
for (int i=0; i < nx;++i){
xx[i] = i*dx;
yy[i] = sin(i*dx) * cos(i*dx);
}
vmin = sfmin(yy, nx), vmax = sfmax(yy, nx);
vmin += (0.2*vmin);
vmax += (0.2*vmax);
for (int i=0; i < nx; ++i){
yy[i] = height-((height / (vmax - vmin)) * yy[i] - ((height *vmin) / (vmax - vmin)));
xx[i] = (width / (xx[nx-1] - xx[0]) )* xx[i] - ((width *xx[0]) / (xx[nx-1] - xx[0]));
}
create_svg(nx,xx,yy);
free(ssh);
free(ssh);
free(xa);
free(xx);
free(yy);
#endif
fclose
(
fin
);
fclose
(
fin
);
return
0
;
return
0
;
...
@@ -77,7 +103,7 @@ void create_svg(int N, float *x, float *y){
...
@@ -77,7 +103,7 @@ void create_svg(int N, float *x, float *y){
FILE
*
fin
=
fopen
(
"obs.svg"
,
"w"
);
FILE
*
fin
=
fopen
(
"obs.svg"
,
"w"
);
fprintf
(
fin
,
"<?xml version=
\"
1.0
\"
encoding=
\"
utf-8
\"
standalone=
\"
no
\"
?>
\n
"
);
fprintf
(
fin
,
"<?xml version=
\"
1.0
\"
encoding=
\"
utf-8
\"
standalone=
\"
no
\"
?>
\n
"
);
fprintf
(
fin
,
"<!DOCTYPE svg PUBLIC
\"
-//W3C//DTD SVG 1.1//EN
\"
\"
http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd
\"
>
\n
"
);
fprintf
(
fin
,
"<!DOCTYPE svg PUBLIC
\"
-//W3C//DTD SVG 1.1//EN
\"
\"
http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd
\"
>
\n
"
);
fprintf
(
fin
,
"<svg height=
\"
492pt
\"
version=
\"
1.1
\"
viewBox=
\"
0 0
761 492
\"
width=
\"
761pt
\"
xmlns=
\"
http://www.w3.org/2000/svg
\"
xmlns:xlink=
\"
http://www.w3.org/1999/xlink
\"
>
\n
"
);
fprintf
(
fin
,
"<svg height=
\"
600px
\"
version=
\"
1.1
\"
viewBox=
\"
0 0
900 600
\"
width=
\"
900px
\"
xmlns=
\"
http://www.w3.org/2000/svg
\"
xmlns:xlink=
\"
http://www.w3.org/1999/xlink
\"
>
\n
"
);
fprintf
(
fin
,
"<defs><style type=
\"
text/css
\"
>*{stroke-linecap:square;stroke-linejoin:round;}</style></defs>"
);
fprintf
(
fin
,
"<defs><style type=
\"
text/css
\"
>*{stroke-linecap:square;stroke-linejoin:round;}</style></defs>"
);
fprintf
(
fin
,
"<g id=
\"
line2d_1
\"
> <path d=
\"\n
"
);
fprintf
(
fin
,
"<g id=
\"
line2d_1
\"
> <path d=
\"\n
"
);
...
@@ -90,7 +116,7 @@ void create_svg(int N, float *x, float *y){
...
@@ -90,7 +116,7 @@ void create_svg(int N, float *x, float *y){
fprintf
(
fin
,
"L%f %f
\n
"
,
x
[
i
],
y
[
i
]);
fprintf
(
fin
,
"L%f %f
\n
"
,
x
[
i
],
y
[
i
]);
}
}
}
}
fprintf
(
fin
,
" style=
\"
fill:none;stroke:#0000
ff
;
\"
"
);
fprintf
(
fin
,
" style=
\"
fill:none;stroke:#
ff
0000;
\"
"
);
fprintf
(
fin
,
"/>
\n
"
);
fprintf
(
fin
,
"/>
\n
"
);
fprintf
(
fin
,
"</g>
\n
"
);
fprintf
(
fin
,
"</g>
\n
"
);
fprintf
(
fin
,
"</svg>"
);
fprintf
(
fin
,
"</svg>"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment