Skip to content

Commit 39eb1a6

Browse files
author
ukmda
authored
Merge pull request #394 from ukmda/master
reverse merge from master
2 parents b66cfac + 0213529 commit 39eb1a6

113 files changed

Lines changed: 70952 additions & 1273 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: build_usermgmt
2+
env:
3+
AWS_REGION: eu-west-2
4+
permissions:
5+
id-token: write
6+
contents: read
7+
8+
on:
9+
push:
10+
branches: [ dev, markmac99, master ]
11+
pull_request:
12+
# The branches below must be a subset of the branches above
13+
branches: [ master ]
14+
jobs:
15+
local_tests:
16+
name: local test stage
17+
runs-on: win10
18+
steps:
19+
- name: "☁️ checkout repository"
20+
uses: actions/checkout@v4
21+
- name: testing
22+
run: |
23+
echo "hello from test"
24+
conda activate ukmon-admin
25+
dir usermgmt\windows
26+
build:
27+
name: build stage
28+
runs-on: win10
29+
needs: local_tests
30+
steps:
31+
- name: building
32+
run: |
33+
echo "running build step"
34+
conda activate ukmon-admin
35+
cd usermgmt\windows
36+
pyinstaller ./stationMaint2.py --noconsole --onefile --windowed --icon .\camera.ico
37+
dir dist
38+
package:
39+
name: package app
40+
runs-on: win10
41+
needs:
42+
- local_tests
43+
- build
44+
steps:
45+
- name: packaging
46+
run: |
47+
echo "packaging the app now"
48+
cd usermgmt\windows\dist
49+
copy ../camera.ico .
50+
((get-content ..\stationmaint.cfg) -replace "adm_mark","") -replace "~/.ssh/ukmonhelper","" | set-content -path ./stationmaint.cfg
51+
compress-archive -path . -update -destinationpath c:\temp\ukmon_usermgmt.zip
52+
release:
53+
name: release package
54+
runs-on: win10
55+
needs:
56+
- local_tests
57+
- build
58+
- package
59+
steps:
60+
- name: release
61+
uses: xresloader/upload-to-github-release@v1
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.MM_PAT }}
64+
with:
65+
file: c:\temp\ukmon_usermgmt.zip
66+
#tags: true
67+
draft: true
68+
overwrite: true
69+
tag_name: 2024.04.02
70+
default_release_name: User Management Tool
71+
default_release_body_path: usermgmt\windows\release_notes.md

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# UK Meteor Data Analysis Shared code and libraries
2+
version: 2024.04.2
23

34
This repository contains the code behind the UK Meteors data archive and data processing pipeline.
45

api_examples/api_examples.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import pandas as pd
2+
import json
3+
import requests
4+
5+
6+
def detectionsExample():
7+
apiurl='https://api.ukmeteors.co.uk/getecsv?stat={}&dt={}'
8+
9+
# retrieve details of a single-station detection at a specific time
10+
stat ='UK0025'
11+
dt = '2021-07-17T02:41:05.05'
12+
res = requests.get(apiurl.format(stat, dt))
13+
if res.status_code == 200:
14+
rawdata=res.text
15+
ecsvlines=rawdata.split('\n') # convert the raw data into a python list
16+
numecsvs = len([e for e in ecsvlines if '# %ECSV' in e]) # find out how many meteors
17+
fnamebase = dt.replace(':','_').replace('.','_') # create an output filename
18+
if numecsvs == 1:
19+
with open(fnamebase + '.ecsv', 'w') as outf:
20+
outf.writelines(ecsvlines)
21+
else:
22+
outf = None
23+
j=1
24+
for i in range(len(ecsvlines)):
25+
if '# %ECSV' in ecsvlines[i]:
26+
if outf is not None:
27+
outf.close()
28+
j=j+1
29+
outf = open(fnamebase + f'_M{j:03d}.ecsv', 'w')
30+
outf.write(f'{ecsvlines[i]}\n')
31+
32+
33+
def matchExampleA():
34+
apiurl = 'https://api.ukmeteors.co.uk/matches'
35+
36+
# get all matched events for a given date
37+
reqtyp = 'matches'
38+
reqval = '20231121'
39+
apicall = '{}?reqtyp={}&reqval={}'.format(apiurl, reqtyp, reqval)
40+
matchlist = pd.read_json(apicall, lines=True)
41+
print(matchlist)
42+
43+
# get details of the 6th event in matchlist
44+
reqtyp = 'detail'
45+
reqval = matchlist.iloc[5].orbname
46+
apicall = '{}?reqtyp={}&reqval={}'.format(apiurl, reqtyp, reqval)
47+
evtdetail = pd.read_json(apicall, typ='series')
48+
print(evtdetail)
49+
50+
# get details for the first five events in the match list
51+
# and put them in a pandas dataframe, then sort by brightest
52+
details=[]
53+
for id in matchlist.head(5).orbname:
54+
reqval = id
55+
apicall = '{}?reqtyp={}&reqval={}'.format(apiurl, reqtyp, reqval)
56+
details.append(pd.read_json(apicall, typ='series'))
57+
df = pd.DataFrame(details)
58+
df = df.sort_values(by=['_mag'])
59+
print(df)
60+
61+
62+
def matchSummaryExample():
63+
apiurl = 'https://api.ukmeteors.co.uk/matches'
64+
65+
# get summary of all events from a specific date
66+
reqtyp = 'summary'
67+
reqval = '20231121'
68+
apicall = '{}?reqtyp={}&reqval={}'.format(apiurl, reqtyp, reqval)
69+
data=requests.get(apicall)
70+
if data.status_code == 200:
71+
df = pd.DataFrame(json.loads(data.text))
72+
print(df._lat1)
73+
print(df.orbname)
74+
rec = df[df._localtime =='_20231121_212437']
75+
print(rec._lat1)
76+
77+
78+
def trajectoryExample():
79+
apiurl = 'https://api.ukmeteors.co.uk/pickle/getpickle'
80+
81+
# get the complete raw and processed data for a given solution
82+
trajid = '20220814_205940.252_UK'
83+
apicall = '{}?reqval={}'.format(apiurl, trajid)
84+
data=requests.get(apicall)
85+
if data.status_code == 200:
86+
traj = json.loads(data.text)
87+
print(traj['jdt_ref'])
88+
89+
# observations contains the raw data
90+
observations = traj['observations']
91+
print(len(observations))
92+
for obs in observations:
93+
k = list(obs.keys())[0]
94+
print(obs[k]['station_id'])
95+
96+
# print all fields
97+
print(traj.keys())

archive/README.md

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ This diagram shows the overall flow of data from Cameras to websites and out to
1212
P -- next day --> D;
1313
D --> E[matching engine];
1414
E --> F[reports generator];
15-
F --> G[opt-in email of matches];
15+
F --> G[match report on groups.io];
1616
F --> I[bad-data alerts];
1717
F --> H[Archive];
18-
H -- on demand --> J[other networks];
19-
H --> M[public];
20-
C --> M[public];
18+
H --> M[website];
19+
C --> M[website];
2120
C --> N{bright event?};
22-
N -->|yes| K[social media];
21+
N --> K[social media];
2322
H -- manual --> K;
2423
I --> O[camera owners];
2524
G --> O;
@@ -43,10 +42,12 @@ This diagram shows the various scripts and processes called, in order
4342
rep3 --> summ[Create summary date for homepage]
4443
summ --> camst[Create Camera status reports]
4544
camst --> exch[Create files for exchange with other networks]
46-
exch --> stats[Create Station Reports]
47-
stats --> mets[Create Metrics]
48-
mets --> badc[Send out bad camera emails]
49-
badc --> d[FINISHED]
45+
exch --> badc[Send out bad camera emails]
46+
badc --> cost[Create Cost Report]
47+
cost --> stats[Create Station Reports]
48+
stats --> clsp[Clear space]
49+
clsp --> mdb[update mariadb tables]
50+
mdb --> d[FINISHED]
5051
```
5152

5253
Find All Matches
@@ -56,33 +57,28 @@ Flow in findAllMatches.sh
5657
```mermaid
5758
flowchart TD
5859
59-
setd[Set the Dates] --> rmssngl[Create RMS single station data files]
60-
rmssngl --> bkp1[Backup the current trajectory database]
61-
bkp1 --> rmat[Invoke runDistrib]
62-
rmat --> start[runDistrib Start calc engine]
63-
start --> creat[runDistrib Create batch script and copy to server]
64-
creat --> sync1[runDistrib script syncs new ftpdetect files]
65-
sync1 --> run[runDistrib Then runs the the Phase 1 solver]
66-
run --> sync2[runDistrib Then syncs back to S3]
67-
sync2 --> done[runDistrib Stop calc engine]
68-
done --> stage2[run the distributed solver phase 2 using ECS and Fargate]
69-
stage2 --> consol[wait for containers to finish then consolidate the data]
70-
consol --> repo[Create file of latest matches]
71-
repo --> stats[Create Stats and sync back to S3]
72-
stats --> idxpg[Update website index pages]
73-
idxpg --> gzi[Backup and gzip old trajectory databases]
74-
gzi --> d[FINISHED]
60+
setd[findAllMatches sets up the date range] --> bkp1[findAllMatches saves the current trajectory database]
61+
bkp1 --> rmat[findAllMatches then invokes runDistrib]
62+
rmat --> start[runDistrib Starts the calc engine server]
63+
start --> creat[runDistrib Creates batch script and copies to calc engine]
64+
creat --> sync1[runDistrib syncs new ftpdetect files to the calc engine]
65+
sync1 --> run[runDistrib runs the the Phase 1 solver. This identifies candidate groups]
66+
run --> sync2[runDistrib syncs data back to the data store]
67+
sync2 --> done[runDistrib stops calc engine for now, to save cost]
68+
done --> stage2[runDistrib starts the distributed solver phase 2 using ECS and Fargate]
69+
stage2 --> consol[runDistrib waits for containers to finish then consolidate the data]
70+
consol --> repo[runDistrib creates file of latest matches]
71+
repo --> stats[runDistrib syncs the solved orbit files back to S3 and backs up the data]
72+
stats --> idxpg[findAllMatches creates some stats, updates website index pages and sends the daily report]
73+
idxpg --> d[FINISHED]
7574
```
7675

7776
Flow in terms of files
7877
======================
7978
```mermaid
8079
flowchart LR
8180
82-
nightly[cronjobs/nightlyJob.sh] --> datasync[utils/dataSync.sh]
83-
nightly --> findmatches[analysis/findAllMatches.sh]
84-
findmatches --> rmssngl[analysis/getRMSSingleData.sh]
85-
findmatches --> srchabl[analysis/createSearchable.sh]
81+
nightly[cronjobs/nightlyJob.sh] --> findmatches[analysis/findAllMatches.sh]
8682
findmatches --> rundist[analysis/runDistrib.sh]
8783
rundist --> trajcont[launches docker containers which solve and post directly to the website]
8884
findmatches --> daily[creates daily report and stats]
@@ -106,8 +102,8 @@ Flow in terms of files
106102
nightly --> statstat[analysis/getBadStations.sh]
107103
nightly --> costs[website/costReport.sh]
108104
nightly --> statreps[analysis/stationReports.sh]
109-
nightly --> databack[utils/dataSyncBack.sh ]
110105
nightly --> clearsp[utils/clearSpace.sh ]
106+
nightly --> mariadb[utils/loadMatchCsvDB.sh ]
111107
nightly --> getlogs[analysis/getLogData.sh]
112108
nightly --> done[done]
113109

archive/analysis/getLogData.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ fi
1616
# create performance metrics
1717
cd $SRC/logs
1818
python -m metrics.timingMetrics $rundate
19-
mv -f $rundate-perfNightly.jpg $DATADIR/
20-
aws s3 cp $DATADIR/$rundate-perfNightly.jpg $WEBSITEBUCKET/reports/batchcharts/ --quiet
19+
aws s3 cp $DATADIR/batchcharts/$rundate-perfNightly.jpg $WEBSITEBUCKET/reports/batchcharts/ --quiet
2120

2221
#lastmtch=$(ls -1tr $SRC/logs/matches-${rundate}-*.log | tail -1)
2322
if [ $rundate != $(date +%Y%m%d) ] ; then

archive/analysis/getRMSSingleData.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ aws s3 mv $indir $outdir --recursive --exclude "*" --include "ukmda_??????_${yr}
3333
mrgfile=$DATADIR/single/singles-${yr}.csv
3434
newsngl=$DATADIR/single/singles-${yr}-new.csv
3535
if [ ! -f $mrgfile ] ; then
36-
echo "Ver,Y,M,D,h,mi,s,Mag,Dur,Az1,Alt1,Az2,Alt2,Ra1,Dec1,Ra2,Dec2,ID,Long,Lat,Alt,Tz,AngVel,Shwr,Filename,Dtstamp" > $mrgfile
36+
cat $SRC/analysis/templates/ukmon-single.txt > $mrgfile
3737
fi
3838
# file containing only new data
39-
echo "Ver,Y,M,D,h,mi,s,Mag,Dur,Az1,Alt1,Az2,Alt2,Ra1,Dec1,Ra2,Dec2,ID,Long,Lat,Alt,Tz,AngVel,Shwr,Filename,Dtstamp" > $newsngl
39+
cat $SRC/analysis/templates/ukmon-single.txt >> $newsngl
4040

4141
ls -1 $outdir/ukmda_??????_${yr}*.csv | while read i
4242
do

0 commit comments

Comments
 (0)