WSL/SLF GitLab Repository
Skip to content
GitLab
Menu
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
42a61ab3
Commit
42a61ab3
authored
May 10, 2012
by
Thomas Egger
Browse files
IOManager.cc: renamed resampled_cache to point_cache, added comments
parent
27f0dc44
Changes
2
Hide whitespace changes
Inline
Side-by-side
meteoio/IOManager.cc
View file @
42a61ab3
...
...
@@ -182,12 +182,12 @@ bool IOManager::read_filtered_cache(const Date& start_date, const Date& end_date
void
IOManager
::
add_to_cache
(
const
Date
&
i_date
,
const
METEO_TIMESERIE
&
vecMeteo
)
{
//Check cache size, delete oldest elements if necessary
if
(
resampled
_cache
.
size
()
>
200
){
resampled
_cache
.
clear
();
//
resampled
_cache.erase(
resampled
_cache.begin(),
resampled
_cache.begin()+50);
if
(
point
_cache
.
size
()
>
200
){
point
_cache
.
clear
();
//
point
_cache.erase(
point
_cache.begin(),
point
_cache.begin()+50);
}
resampled
_cache
[
i_date
]
=
vecMeteo
;
point
_cache
[
i_date
]
=
vecMeteo
;
}
//data can be raw or processed (filtered, resampled)
...
...
@@ -198,7 +198,7 @@ size_t IOManager::getMeteoData(const Date& i_date, METEO_TIMESERIE& vecMeteo)
vector
<
vector
<
MeteoData
>
>
vec_cache
;
//1. Check whether user wants raw data or processed data
//The first case: we are looking at raw data directly, only unresampled values are considered
//The first case: we are looking at raw data directly, only unresampled values are considered
, exact date match
if
(
processing_level
==
IOManager
::
raw
)
{
rawio
.
readMeteoData
(
i_date
-
Duration
(
1.
/
(
24.
*
3600.
),
0.
),
i_date
+
Duration
(
1.
/
(
24.
*
3600.
),
0.
),
vec_cache
);
for
(
size_t
ii
=
0
;
ii
<
vec_cache
.
size
();
ii
++
){
...
...
@@ -211,15 +211,15 @@ size_t IOManager::getMeteoData(const Date& i_date, METEO_TIMESERIE& vecMeteo)
}
//2. Check which data point is available, buffered locally
, HACK: resampled_cache is a misleading name
map
<
Date
,
vector
<
MeteoData
>
>::
const_iterator
it
=
resampled
_cache
.
find
(
i_date
);
if
(
it
!=
resampled
_cache
.
end
()){
//2. Check which data point is available, buffered locally
map
<
Date
,
vector
<
MeteoData
>
>::
const_iterator
it
=
point
_cache
.
find
(
i_date
);
if
(
it
!=
point
_cache
.
end
()){
vecMeteo
=
it
->
second
;
return
vecMeteo
.
size
();
}
//Let's make sure we have the data we need, in the filtered_cache or in vec_cache
vector
<
vector
<
MeteoData
>
>*
data
=
NULL
;
vector
<
vector
<
MeteoData
>
>*
data
=
NULL
;
//reference to either filtered_cache or vec_cache
if
((
IOManager
::
filtered
&
processing_level
)
==
IOManager
::
filtered
){
if
((
fcache_start
<=
i_date
-
proc_properties
.
time_before
)
&&
(
fcache_end
>=
i_date
+
proc_properties
.
time_after
))
{
//already cached data
...
...
@@ -235,12 +235,11 @@ size_t IOManager::getMeteoData(const Date& i_date, METEO_TIMESERIE& vecMeteo)
}
for
(
size_t
ii
=
0
;
ii
<
(
*
data
).
size
();
ii
++
)
{
//for every station
if
((
IOManager
::
resampled
&
processing_level
)
!=
IOManager
::
resampled
)
{
//
only filtering activat
ed
const
size_t
index
=
IOUtils
::
seek
(
i_date
,
(
*
data
)[
ii
],
true
);
if
((
IOManager
::
resampled
&
processing_level
)
!=
IOManager
::
resampled
)
{
//
no resampling requir
ed
const
size_t
index
=
IOUtils
::
seek
(
i_date
,
(
*
data
)[
ii
],
true
);
//needs to be an exact match
if
(
index
!=
IOUtils
::
npos
)
vecMeteo
.
push_back
((
*
data
)[
ii
][
index
]);
//Insert station into vecMeteo
}
else
{
//resampling required
}
else
{
//resampling required
MeteoData
md
;
const
bool
success
=
meteoprocessor
.
resample
(
i_date
,
(
*
data
)[
ii
],
md
);
...
...
@@ -461,8 +460,8 @@ std::string IOManager::toString() const {
size_t
count
=
0
;
size_t
min_stations
=
std
::
numeric_limits
<
size_t
>::
max
();
size_t
max_stations
=
0
;
std
::
map
<
Date
,
std
::
vector
<
MeteoData
>
>::
const_iterator
iter
=
resampled
_cache
.
begin
();
for
(;
iter
!=
resampled
_cache
.
end
();
iter
++
)
{
std
::
map
<
Date
,
std
::
vector
<
MeteoData
>
>::
const_iterator
iter
=
point
_cache
.
begin
();
for
(;
iter
!=
point
_cache
.
end
();
iter
++
)
{
const
size_t
nb_stations
=
iter
->
second
.
size
();
if
(
nb_stations
>
max_stations
)
max_stations
=
nb_stations
;
if
(
nb_stations
<
min_stations
)
min_stations
=
nb_stations
;
...
...
@@ -479,10 +478,10 @@ std::string IOManager::toString() const {
else
os
<<
min_stations
<<
" to "
<<
max_stations
;
os
<<
" station(s))
\n
"
;
os
<<
resampled
_cache
.
begin
()
->
first
.
toString
(
Date
::
ISO
)
<<
" - 1 timestep
\n
"
;
os
<<
point
_cache
.
begin
()
->
first
.
toString
(
Date
::
ISO
)
<<
" - 1 timestep
\n
"
;
}
if
(
count
>
1
)
{
const
double
avg_sampling
=
(
(
resampled
_cache
.
rbegin
()
->
first
.
getJulianDate
())
-
(
resampled
_cache
.
begin
()
->
first
.
getJulianDate
())
)
/
(
double
)(
count
-
1
);
const
double
avg_sampling
=
(
(
point
_cache
.
rbegin
()
->
first
.
getJulianDate
())
-
(
point
_cache
.
begin
()
->
first
.
getJulianDate
())
)
/
(
double
)(
count
-
1
);
os
<<
"Resampled cache content ("
;
if
(
max_stations
==
min_stations
)
...
...
@@ -490,8 +489,8 @@ std::string IOManager::toString() const {
else
os
<<
min_stations
<<
" to "
<<
max_stations
;
os
<<
" station(s))
\n
"
;
os
<<
resampled
_cache
.
begin
()
->
first
.
toString
(
Date
::
ISO
);
os
<<
" - "
<<
resampled
_cache
.
rbegin
()
->
first
.
toString
(
Date
::
ISO
);
os
<<
point
_cache
.
begin
()
->
first
.
toString
(
Date
::
ISO
);
os
<<
" - "
<<
point
_cache
.
rbegin
()
->
first
.
toString
(
Date
::
ISO
);
os
<<
" - "
<<
count
<<
" timesteps ("
<<
setprecision
(
3
)
<<
fixed
<<
avg_sampling
*
24.
*
3600.
<<
" s sampling rate)"
;
}
...
...
meteoio/IOManager.h
View file @
42a61ab3
...
...
@@ -244,7 +244,7 @@ class IOManager {
Meteo2DInterpolator
interpolator
;
ProcessingProperties
proc_properties
;
///< buffer constraints in order to be able to compute the requested values
std
::
map
<
Date
,
METEO_TIMESERIE
>
resampled
_cache
;
///< stores already resampled data points
std
::
map
<
Date
,
METEO_TIMESERIE
>
point
_cache
;
///< stores already resampled data points
std
::
vector
<
METEO_TIMESERIE
>
filtered_cache
;
///< stores already filtered data intervals
Date
fcache_start
,
fcache_end
;
///< store the beginning and the end date of the filtered_cache
unsigned
int
processing_level
;
...
...
Write
Preview
Supports
Markdown
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