WSL/SLF GitLab Repository
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
snow-models
meteoio
Commits
79629021
Commit
79629021
authored
Sep 13, 2013
by
Mathias Bavay
Browse files
Still size_t stuff...
parent
3933137d
Changes
6
Hide whitespace changes
Inline
Side-by-side
meteoio/DEMObject.cc
View file @
79629021
...
...
@@ -856,7 +856,7 @@ double DEMObject::getCurvature(double A[4][4]) {
count
++
;
}
if
(
count
!=
0.
)
return
1.
/
count
*
sum
;
if
(
count
!=
0.
)
return
1.
/
(
double
)
count
*
sum
;
}
curvature_failures
++
;
return
IOUtils
::
nodata
;
...
...
@@ -967,15 +967,15 @@ double DEMObject::avgHeight(const double& z1, const double &z2, const double& z3
void
DEMObject
::
getNeighbours
(
const
size_t
i
,
const
size_t
j
,
double
A
[
4
][
4
])
{
//this fills a 3x3 table containing the neighboring values
A
[
1
][
1
]
=
safeGet
(
i
-
1
,
j
+
1
);
A
[
1
][
2
]
=
safeGet
(
i
,
j
+
1
);
A
[
1
][
3
]
=
safeGet
(
i
+
1
,
j
+
1
);
A
[
2
][
1
]
=
safeGet
(
i
-
1
,
j
);
A
[
2
][
2
]
=
safeGet
(
i
,
j
);
A
[
2
][
3
]
=
safeGet
(
i
+
1
,
j
);
A
[
3
][
1
]
=
safeGet
(
i
-
1
,
j
-
1
);
A
[
3
][
2
]
=
safeGet
(
i
,
j
-
1
);
A
[
3
][
3
]
=
safeGet
(
i
+
1
,
j
-
1
);
A
[
1
][
1
]
=
safeGet
(
(
signed
)
i
-
1
,
(
signed
)
j
+
1
);
A
[
1
][
2
]
=
safeGet
(
(
signed
)
i
,
(
signed
)
j
+
1
);
A
[
1
][
3
]
=
safeGet
(
(
signed
)
i
+
1
,
(
signed
)
j
+
1
);
A
[
2
][
1
]
=
safeGet
(
(
signed
)
i
-
1
,
(
signed
)
j
);
A
[
2
][
2
]
=
safeGet
(
(
signed
)
i
,
(
signed
)
j
);
A
[
2
][
3
]
=
safeGet
(
(
signed
)
i
+
1
,
(
signed
)
j
);
A
[
3
][
1
]
=
safeGet
(
(
signed
)
i
-
1
,
(
signed
)
j
-
1
);
A
[
3
][
2
]
=
safeGet
(
(
signed
)
i
,
(
signed
)
j
-
1
);
A
[
3
][
3
]
=
safeGet
(
(
signed
)
i
+
1
,
(
signed
)
j
-
1
);
}
double
DEMObject
::
safeGet
(
const
int
i
,
const
int
j
)
...
...
meteoio/ResamplingAlgorithms2D.cc
View file @
79629021
...
...
@@ -30,8 +30,8 @@ namespace mio {
const
Grid2DObject
ResamplingAlgorithms2D
::
BilinearResampling
(
const
Grid2DObject
&
i_grid
,
const
double
&
factor
)
{
const
double
cellsize
=
i_grid
.
cellsize
/
factor
;
const
size_t
ncols
=
(
size_t
)
Optim
::
round
(
i_grid
.
ncols
*
factor
);
const
size_t
nrows
=
(
size_t
)
Optim
::
round
(
i_grid
.
nrows
*
factor
);
const
size_t
ncols
=
static_cast
<
size_t
>
(
Optim
::
round
(
static_cast
<
double
>
(
i_grid
.
ncols
)
*
factor
)
);
const
size_t
nrows
=
static_cast
<
size_t
>
(
Optim
::
round
(
static_cast
<
double
>
(
i_grid
.
nrows
)
*
factor
)
);
Grid2DObject
o_grid
(
ncols
,
nrows
,
cellsize
,
i_grid
.
llcorner
);
Bilinear
(
o_grid
,
i_grid
);
//GridObjects always keep nodata
...
...
@@ -41,8 +41,8 @@ const Grid2DObject ResamplingAlgorithms2D::BilinearResampling(const Grid2DObject
const
Grid2DObject
ResamplingAlgorithms2D
::
cubicBSplineResampling
(
const
Grid2DObject
&
i_grid
,
const
double
&
factor
)
{
const
double
cellsize
=
i_grid
.
cellsize
/
factor
;
const
size_t
ncols
=
(
size_t
)
Optim
::
round
(
i_grid
.
ncols
*
factor
);
const
size_t
nrows
=
(
size_t
)
Optim
::
round
(
i_grid
.
nrows
*
factor
);
const
size_t
ncols
=
static_cast
<
size_t
>
(
Optim
::
round
(
static_cast
<
double
>
(
i_grid
.
ncols
)
*
factor
)
);
const
size_t
nrows
=
static_cast
<
size_t
>
(
Optim
::
round
(
static_cast
<
double
>
(
i_grid
.
nrows
)
*
factor
)
);
Grid2DObject
o_grid
(
ncols
,
nrows
,
cellsize
,
i_grid
.
llcorner
);
cubicBSpline
(
o_grid
,
i_grid
);
//GridObjects always keep nodata
...
...
@@ -52,8 +52,8 @@ const Grid2DObject ResamplingAlgorithms2D::cubicBSplineResampling(const Grid2DOb
const
Grid2DObject
ResamplingAlgorithms2D
::
NearestNeighbour
(
const
Grid2DObject
&
i_grid
,
const
double
&
factor
)
{
const
double
cellsize
=
i_grid
.
cellsize
/
factor
;
const
size_t
ncols
=
(
size_t
)
Optim
::
round
(
i_grid
.
ncols
*
factor
);
const
size_t
nrows
=
(
size_t
)
Optim
::
round
(
i_grid
.
nrows
*
factor
);
const
size_t
ncols
=
static_cast
<
size_t
>
(
Optim
::
round
(
static_cast
<
double
>
(
i_grid
.
ncols
)
*
factor
)
);
const
size_t
nrows
=
static_cast
<
size_t
>
(
Optim
::
round
(
static_cast
<
double
>
(
i_grid
.
nrows
)
*
factor
)
);
Grid2DObject
o_grid
(
ncols
,
nrows
,
cellsize
,
i_grid
.
llcorner
);
NearestNeighbour
(
o_grid
,
i_grid
);
//GridObjects always keep nodata
...
...
meteoio/meteostats/libfit1DCore.cc
View file @
79629021
...
...
@@ -141,8 +141,8 @@ bool FitLeastSquare::computeFit() {
Matrix
dLambda
;
//parameters variations
initDLambda
(
dLambda
);
Matrix
A
(
(
unsigned
int
)
nPts
,
(
unsigned
int
)
nParam
);
Matrix
dBeta
(
nPts
,
(
unsigned
in
t
)
1
);
Matrix
A
(
nPts
,
nParam
);
Matrix
dBeta
(
nPts
,
(
size_
t
)
1
);
unsigned
int
iter
=
0
;
do
{
...
...
meteoio/plugins/ARCIO.cc
View file @
79629021
...
...
@@ -352,11 +352,13 @@ void ARCIO::write2DGrid(const Grid2DObject& grid_in, const std::string& name)
fout
<<
"cellsize "
<<
setw
(
23
-
9
)
<<
setprecision
(
3
)
<<
grid_in
.
cellsize
<<
"
\n
"
;
fout
<<
"NODATA_value "
<<
(
int
)(
IOUtils
::
nodata
)
<<
"
\n
"
;
for
(
unsigned
int
kk
=
grid_in
.
nrows
-
1
;
kk
<
grid_in
.
nrows
;
kk
--
)
{
for
(
unsigned
int
ll
=
0
;
ll
<
grid_in
.
ncols
;
ll
++
){
fout
<<
grid_in
.
grid2D
(
ll
,
kk
)
<<
" "
;
if
(
grid_in
.
nrows
>
0
)
{
for
(
size_t
kk
=
grid_in
.
nrows
-
1
;
kk
<
grid_in
.
nrows
;
kk
--
)
{
for
(
size_t
ll
=
0
;
ll
<
grid_in
.
ncols
;
ll
++
){
fout
<<
grid_in
.
grid2D
(
ll
,
kk
)
<<
" "
;
}
fout
<<
"
\n
"
;
}
fout
<<
"
\n
"
;
}
}
catch
(...)
{
cerr
<<
"[E] error when writing ARC grid
\"
"
<<
full_name
<<
"
\"
"
<<
AT
<<
": "
<<
endl
;
...
...
meteoio/plugins/GrassIO.cc
View file @
79629021
...
...
@@ -239,30 +239,32 @@ void GrassIO::write2DGrid(const Grid2DObject& grid_in, const std::string& name)
fout
<<
setprecision
(
6
)
<<
fixed
;
try
{
fout
<<
"north:"
<<
(
llcorner
.
getNorthing
()
+
grid_in
.
cellsize
*
grid_in
.
nrows
)
<<
"
\n
"
;
fout
<<
"north:"
<<
(
llcorner
.
getNorthing
()
+
grid_in
.
cellsize
*
(
double
)
grid_in
.
nrows
)
<<
"
\n
"
;
fout
<<
"south:"
<<
llcorner
.
getNorthing
()
<<
"
\n
"
;
fout
<<
"east:"
<<
(
llcorner
.
getEasting
()
+
grid_in
.
cellsize
*
grid_in
.
ncols
)
<<
"
\n
"
;
fout
<<
"east:"
<<
(
llcorner
.
getEasting
()
+
grid_in
.
cellsize
*
(
double
)
grid_in
.
ncols
)
<<
"
\n
"
;
fout
<<
"west:"
<<
llcorner
.
getEasting
()
<<
"
\n
"
;
fout
<<
"rows:"
<<
grid_in
.
nrows
<<
"
\n
"
;
fout
<<
"cols:"
<<
grid_in
.
ncols
<<
"
\n
"
;
for
(
unsigned
int
kk
=
grid_in
.
nrows
-
1
;
kk
<
grid_in
.
nrows
;
kk
--
)
{
unsigned
int
ll
=
0
;
for
(
ll
=
0
;
ll
<
(
grid_in
.
ncols
-
1
);
ll
++
){
if
(
grid_in
.
nrows
>
0
)
{
for
(
size_t
kk
=
grid_in
.
nrows
-
1
;
kk
<
grid_in
.
nrows
;
kk
--
)
{
size_t
ll
=
0
;
for
(
ll
=
0
;
ll
<
(
grid_in
.
ncols
-
1
);
ll
++
){
if
(
grid_in
.
grid2D
(
ll
,
kk
)
==
IOUtils
::
nodata
)
{
fout
<<
"* "
;
}
else
{
fout
<<
grid_in
.
grid2D
(
ll
,
kk
)
<<
" "
;
}
}
//The last value in a line does not have a trailing " "
if
(
grid_in
.
grid2D
(
ll
,
kk
)
==
IOUtils
::
nodata
)
{
fout
<<
"*
"
;
fout
<<
"*"
;
}
else
{
fout
<<
grid_in
.
grid2D
(
ll
,
kk
)
<<
" "
;
fout
<<
grid_in
.
grid2D
(
ll
,
kk
);
}
fout
<<
"
\n
"
;
}
//The last value in a line does not have a trailing " "
if
(
grid_in
.
grid2D
(
ll
,
kk
)
==
IOUtils
::
nodata
)
{
fout
<<
"*"
;
}
else
{
fout
<<
grid_in
.
grid2D
(
ll
,
kk
);
}
fout
<<
"
\n
"
;
}
}
catch
(
const
std
::
exception
&
e
)
{
cerr
<<
"[E] "
<<
AT
<<
": "
<<
e
.
what
()
<<
std
::
endl
;
...
...
meteoio/plugins/PGMIO.cc
View file @
79629021
...
...
@@ -278,15 +278,17 @@ void PGMIO::write2DGrid(const Grid2DObject& grid_in, const std::string& name)
fout
<<
nr_colors
<<
"
\n
"
;
//writing the data
for
(
unsigned
int
kk
=
grid_in
.
nrows
-
1
;
kk
<
grid_in
.
nrows
;
kk
--
)
{
for
(
unsigned
int
ll
=
0
;
ll
<
grid_in
.
ncols
;
ll
++
)
{
const
double
value
=
grid_in
.
grid2D
(
ll
,
kk
);
if
(
value
!=
IOUtils
::
nodata
)
fout
<<
static_cast
<
unsigned
int
>
(
floor
((
grid_in
.
grid2D
(
ll
,
kk
)
-
min_value
)
*
scaling
)
+
1
)
<<
" "
;
else
fout
<<
"0"
<<
" "
;
if
(
grid_in
.
nrows
>
0
)
{
for
(
size_t
kk
=
grid_in
.
nrows
-
1
;
kk
<
grid_in
.
nrows
;
kk
--
)
{
for
(
size_t
ll
=
0
;
ll
<
grid_in
.
ncols
;
ll
++
)
{
const
double
value
=
grid_in
.
grid2D
(
ll
,
kk
);
if
(
value
!=
IOUtils
::
nodata
)
fout
<<
static_cast
<
unsigned
int
>
(
floor
((
grid_in
.
grid2D
(
ll
,
kk
)
-
min_value
)
*
scaling
)
+
1
)
<<
" "
;
else
fout
<<
"0"
<<
" "
;
}
fout
<<
"
\n
"
;
}
fout
<<
"
\n
"
;
}
}
catch
(...)
{
cerr
<<
"[E] error when writing PGM grid
\"
"
<<
full_name
<<
"
\"
"
<<
AT
<<
": "
<<
endl
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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