Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
68798d80
Commit
68798d80
authored
3 months ago
by
Shavers, Nicholas H
Browse files
Options
Downloads
Patches
Plain Diff
with compression at the file level
parent
41e88066
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!368
Imagcdf factory mvp
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/ImagCDFFactory.py
+13
-6
13 additions, 6 deletions
geomagio/ImagCDFFactory.py
with
13 additions
and
6 deletions
geomagio/ImagCDFFactory.py
+
13
−
6
View file @
68798d80
...
@@ -129,12 +129,20 @@ class ImagCDFFactory(TimeseriesFactory):
...
@@ -129,12 +129,20 @@ class ImagCDFFactory(TimeseriesFactory):
def
write_file
(
self
,
fh
,
timeseries
:
Stream
,
channels
:
List
[
str
]):
def
write_file
(
self
,
fh
,
timeseries
:
Stream
,
channels
:
List
[
str
]):
# Create a temporary file to write the CDF data
# Create a temporary file to write the CDF data
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
)
as
tmp_file
:
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
,
suffix
=
'
.cdf
'
)
as
tmp_file
:
tmp_file_path
=
tmp_file
.
name
+
"
.cdf
"
tmp_file_path
=
tmp_file
.
name
try
:
try
:
# Initialize the CDF writer
# Initialize the CDF writer
cdf_writer
=
cdflib
.
cdfwrite
.
CDF
(
tmp_file_path
)
cdf_spec
=
{
'
Compressed
'
:
9
,
# Enable compression (0-9)
# 'Majority': 'row_major', # Data layout - gets set automatically
# 'Encoding': 'ibmpc', # Corrupts CDF - gets set automatically
'
Checksum
'
:
True
,
# Disable checksum for faster writes (optional)
'
rDim_sizes
'
:
[],
# Applicable only if using rVariables - CDF protocol recommends only using zVariables.
}
cdf_writer
=
cdflib
.
cdfwrite
.
CDF
(
path
=
tmp_file_path
,
cdf_spec
=
cdf_spec
,
delete
=
True
)
# Write global attributes
# Write global attributes
global_attrs
=
self
.
_create_global_attributes
(
timeseries
,
channels
)
global_attrs
=
self
.
_create_global_attributes
(
timeseries
,
channels
)
...
@@ -206,7 +214,6 @@ class ImagCDFFactory(TimeseriesFactory):
...
@@ -206,7 +214,6 @@ class ImagCDFFactory(TimeseriesFactory):
# Cleanup the temporary file
# Cleanup the temporary file
os
.
remove
(
tmp_file_path
)
os
.
remove
(
tmp_file_path
)
def
put_timeseries
(
def
put_timeseries
(
self
,
self
,
timeseries
:
Stream
,
timeseries
:
Stream
,
...
@@ -288,7 +295,7 @@ class ImagCDFFactory(TimeseriesFactory):
...
@@ -288,7 +295,7 @@ class ImagCDFFactory(TimeseriesFactory):
# Read existing data to merge with new data
# Read existing data to merge with new data
existing_cdf
=
cdflib
.
cdfread
.
CDF
(
url_file
)
existing_cdf
=
cdflib
.
cdfread
.
CDF
(
url_file
)
existing_stream
=
self
.
_read_cdf
(
existing_cdf
)
existing_stream
=
self
.
_read_cdf
(
existing_cdf
)
existing_cdf
.
close
()
#
existing_cdf.close()
#no close method?
existing_data
=
existing_stream
existing_data
=
existing_stream
# Merge existing data with new data
# Merge existing data with new data
...
@@ -480,7 +487,7 @@ class ImagCDFFactory(TimeseriesFactory):
...
@@ -480,7 +487,7 @@ class ImagCDFFactory(TimeseriesFactory):
elif
channel
in
TEMPERATURE_ELEMENTS_ID
:
elif
channel
in
TEMPERATURE_ELEMENTS_ID
:
units
=
'
Celsius
'
units
=
'
Celsius
'
fieldnam
=
f
"
Temperature
{
temperature_index
}
{
trace
.
stats
.
location
}
"
fieldnam
=
f
"
Temperature
{
temperature_index
}
{
trace
.
stats
.
location
}
"
validmin
=
-
273.15
validmin
=
-
273.15
#absolute zero
validmax
=
79_999
validmax
=
79_999
elif
channel
in
[
'
F
'
,
'
S
'
]:
elif
channel
in
[
'
F
'
,
'
S
'
]:
units
=
'
nT
'
units
=
'
nT
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment