Skip to content

Commit

Permalink
Merge pull request #23 from tskisner/format
Browse files Browse the repository at this point in the history
Enforce coding format with uncrustify and black.
  • Loading branch information
tskisner authored May 17, 2019
2 parents ecd4826 + eb8a4a8 commit 8f8f4b8
Show file tree
Hide file tree
Showing 66 changed files with 8,465 additions and 8,231 deletions.
24 changes: 24 additions & 0 deletions .atom/config.cson
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"*":
"atom-beautify":
c:
beautify_on_save: true
configPath: "src/uncrustify.cfg"
cpp:
beautify_on_save: true
configPath: "src/uncrustify.cfg"
python: {}
editor:
autoIndentOnPaste: false
fontSize: 18
preferredLineLength: 88
scrollPastEnd: true
showInvisibles: true
softWrap: true
softWrapAtPreferredLineLength: true
tabLength: 4
tabType: "soft"
"linter-flake8":
maxLineLength: 88
"python-black":
fmtOnSave: true
lineLength: 88
155 changes: 91 additions & 64 deletions examples/demo_telescope.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python3
##
## TImestream DAta Storage (TIDAS)
## Copyright (c) 2014-2018, all rights reserved. Use of this source code
## is governed by a BSD-style license that can be found in the top-level
## LICENSE file.
##
#
# TImestream DAta Storage (TIDAS).
#
# Copyright (c) 2015-2019 by the parties listed in the AUTHORS file. All rights
# reserved. Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# WARNING: Running this script will generate a several GB of data...

Expand Down Expand Up @@ -37,12 +37,12 @@
# ---- Data from a weather station ----

wfields = list()
wfields.append( tidas.Field("windspeed", tdt.float32, "Meters / second") )
wfields.append( tidas.Field("windangle", tdt.float32, "Degrees") )
wfields.append( tidas.Field("temperature", tdt.float32, "Degrees Celsius") )
wfields.append( tidas.Field("pressure", tdt.float32, "Millibars") )
wfields.append( tidas.Field("humidity", tdt.float32, "Percent") )
wfields.append( tidas.Field("PWV", tdt.float32, "mm") )
wfields.append(tidas.Field("windspeed", tdt.float32, "Meters / second"))
wfields.append(tidas.Field("windangle", tdt.float32, "Degrees"))
wfields.append(tidas.Field("temperature", tdt.float32, "Degrees Celsius"))
wfields.append(tidas.Field("pressure", tdt.float32, "Millibars"))
wfields.append(tidas.Field("humidity", tdt.float32, "Percent"))
wfields.append(tidas.Field("PWV", tdt.float32, "mm"))
weather_schema = tidas.Schema(wfields)

# sampled every 10 seconds
Expand All @@ -52,8 +52,8 @@
# ---- Housekeeping data ----

hfields = list()
hfields.append( tidas.Field("thermo1", tdt.float32, "Degrees Kelvin") )
hfields.append( tidas.Field("thermo2", tdt.float32, "Degrees Kelvin") )
hfields.append(tidas.Field("thermo1", tdt.float32, "Degrees Kelvin"))
hfields.append(tidas.Field("thermo2", tdt.float32, "Degrees Kelvin"))
hk_schema = tidas.Schema(hfields)

# sampled once per minute
Expand All @@ -63,9 +63,9 @@
# ---- Pointing data ----

pfields = list()
pfields.append( tidas.Field("az", tdt.float32, "Radians") )
pfields.append( tidas.Field("el", tdt.float32, "Radians") )
pfields.append( tidas.Field("psi", tdt.float32, "Radians") )
pfields.append(tidas.Field("az", tdt.float32, "Radians"))
pfields.append(tidas.Field("el", tdt.float32, "Radians"))
pfields.append(tidas.Field("psi", tdt.float32, "Radians"))
pointing_schema = tidas.Schema(pfields)

# sampled at 20 Hz
Expand All @@ -80,7 +80,7 @@

for d in range(ndet):
detname = "det_{:04d}".format(d)
dfields.append( tidas.Field(detname, tdt.int16, "ADU") )
dfields.append(tidas.Field(detname, tdt.int16, "ADU"))

det_schema = tidas.Schema(dfields)

Expand All @@ -98,16 +98,15 @@
# Create the volume all at once. To keep the size of the volume
# reasonable for this demo, only write 3 days of data.

vol = tidas.Volume(path, tidas.BackendType.hdf5,
tidas.CompressionType.none, dict())
vol = tidas.Volume(path, tidas.BackendType.hdf5, tidas.CompressionType.none, dict())

# Get the root block of the volume
root = vol.root()

volstart = datetime.datetime(2018, 1, 1)
volstartsec = volstart.timestamp()

for year in ["2018",]:
for year in ["2018"]:
# Add a block for this year
yb = root.block_add(year, tidas.Block())

Expand All @@ -120,8 +119,7 @@
for dy in range(1, 4):

daystart = datetime.datetime(int(year), monthnum, dy)
daystartsec = (daystart - volstart).total_seconds() \
+ volstartsec
daystartsec = (daystart - volstart).total_seconds() + volstartsec

# Add a block for the day
day = "{:02d}".format(dy)
Expand All @@ -137,83 +135,112 @@

print(" writing weather data")

weather = tidas.Group(weather_schema, tidas.Dictionary(),
weather_daysamples)
weather = tidas.Group(
weather_schema, tidas.Dictionary(), weather_daysamples
)
weather = db.group_add("weather", weather)
weather.write_times(0, np.linspace(daystartsec,
daystartsec + day_seconds, num=weather_daysamples))

data = np.absolute(np.random.normal(loc=0.0, scale=5.0,
size=weather_daysamples)).astype(np.float32)
weather.write_times(
0,
np.linspace(
daystartsec, daystartsec + day_seconds, num=weather_daysamples
),
)

data = np.absolute(
np.random.normal(loc=0.0, scale=5.0, size=weather_daysamples)
).astype(np.float32)
weather.write("windspeed", 0, data)

data = 360.0 * np.absolute(np.random.random(
size=weather_daysamples)).astype(np.float32)
data = 360.0 * np.absolute(
np.random.random(size=weather_daysamples)
).astype(np.float32)
weather.write("windangle", 0, data)

data = np.absolute(np.random.normal(loc=25.0, scale=5.0,
size=weather_daysamples)).astype(np.float32)
data = np.absolute(
np.random.normal(loc=25.0, scale=5.0, size=weather_daysamples)
).astype(np.float32)
weather.write("temperature", 0, data)

data = np.absolute(np.random.normal(loc=1013.25, scale=30.0,
size=weather_daysamples)).astype(np.float32)
data = np.absolute(
np.random.normal(loc=1013.25, scale=30.0, size=weather_daysamples)
).astype(np.float32)
weather.write("pressure", 0, data)

data = np.absolute(np.random.normal(loc=30.0, scale=10.0,
size=weather_daysamples)).astype(np.float32)
data = np.absolute(
np.random.normal(loc=30.0, scale=10.0, size=weather_daysamples)
).astype(np.float32)
weather.write("humidity", 0, data)

data = np.absolute(np.random.normal(loc=10.0, scale=5.0,
size=weather_daysamples)).astype(np.float32)
data = np.absolute(
np.random.normal(loc=10.0, scale=5.0, size=weather_daysamples)
).astype(np.float32)
weather.write("PWV", 0, data)

print(" writing housekeeping data")

hk = tidas.Group(hk_schema, tidas.Dictionary(), hk_daysamples)
hk = db.group_add("hk", hk)
hk.write_times(0, np.linspace(daystartsec,
daystartsec + day_seconds, num=hk_daysamples))

data = np.random.normal(loc=273.0, scale=5.0,
size=hk_daysamples).astype(np.float32)
hk.write_times(
0,
np.linspace(daystartsec, daystartsec + day_seconds, num=hk_daysamples),
)

data = np.random.normal(loc=273.0, scale=5.0, size=hk_daysamples).astype(
np.float32
)
hk.write("thermo1", 0, data)

data = np.random.normal(loc=77.0, scale=5.0,
size=hk_daysamples).astype(np.float32)
data = np.random.normal(loc=77.0, scale=5.0, size=hk_daysamples).astype(
np.float32
)
hk.write("thermo2", 0, data)

print(" writing pointing data")

pointing = tidas.Group(pointing_schema, tidas.Dictionary(),
pointing_daysamples)
pointing = tidas.Group(
pointing_schema, tidas.Dictionary(), pointing_daysamples
)
pointing = db.group_add("pointing", pointing)
pointing.write_times(0, np.linspace(daystartsec,
daystartsec + day_seconds, num=pointing_daysamples))

data = 2.0 * np.pi * np.random.random(
size=pointing_daysamples).astype(np.float32)
pointing.write_times(
0,
np.linspace(
daystartsec, daystartsec + day_seconds, num=pointing_daysamples
),
)

data = (
2.0
* np.pi
* np.random.random(size=pointing_daysamples).astype(np.float32)
)
pointing.write("az", 0, data)

data = 0.4 * np.pi * np.random.random(
size=pointing_daysamples).astype(np.float32)
data = (
0.4
* np.pi
* np.random.random(size=pointing_daysamples).astype(np.float32)
)
pointing.write("el", 0, data)

data = np.random.normal(loc=0.0, scale=(0.01*np.pi),
size=pointing_daysamples).astype(np.float32)
data = np.random.normal(
loc=0.0, scale=(0.01 * np.pi), size=pointing_daysamples
).astype(np.float32)
pointing.write("psi", 0, data)

print(" writing detector data")

det = tidas.Group(det_schema, tidas.Dictionary(),
det_daysamples)
det = tidas.Group(det_schema, tidas.Dictionary(), det_daysamples)
det = db.group_add("detectors", det)
det.write_times(0, np.linspace(daystartsec,
daystartsec + day_seconds, num=det_daysamples))
det.write_times(
0,
np.linspace(daystartsec, daystartsec + day_seconds, num=det_daysamples),
)

for d in range(ndet):
detname = "det_{:04d}".format(d)
data = np.random.normal(loc=32768, scale=2000,
size=det_daysamples).astype(np.int16)
data = np.random.normal(
loc=32768, scale=2000, size=det_daysamples
).astype(np.int16)
det.write(detname, 0, data)

# Take a quick peek at organization:
Expand Down
Loading

0 comments on commit 8f8f4b8

Please sign in to comment.