-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_ancilla_meas.sh
executable file
·48 lines (37 loc) · 1.15 KB
/
get_ancilla_meas.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
KEY="$1"
JOB_IDS_FILE="job_ids.txt" # The file containing the list of job IDs
# Check if the job IDs file exists
if [ ! -f "$JOB_IDS_FILE" ]; then
echo "Job IDs file does not exist: $JOB_IDS_FILE"
exit 1
fi
n=0
probs=()
# Iterate over each job ID in the file and collect histograms
while IFS= read -r JOB_ID; do
# Ensure the JOB_ID is not empty
if [ -z "$JOB_ID" ]; then
continue
fi
((n++))
job_result=$(./retrieve-job.sh $KEY $JOB_ID)
if [ $? -ne 0 ]; then
echo "Failed to retrieve job $JOB_ID"
continue
fi
# Extract the histogram as a JSON string
histogram=$(echo $job_result | jq -r '.data.histogram | @json')
if [ "$histogram" == "null" ]; then
echo "Histogram not found for job $JOB_ID"
continue
fi
#echo "Histogram for job $JOB_ID: $histogram"
# Pass the histogram to the Python script for calculation
prob_ancillas=$(echo $histogram | python3 ancilla_meas.py --n "$n")
#echo "Probabilities for job $JOB_ID: $prob_ancillas"
probs+=("$prob_ancillas")
done < "$JOB_IDS_FILE"
for prob_array in "${probs[@]}"; do
echo "$prob_array"
done