<jupyter_start><jupyter_text>Imports<jupyter_code>import pyaurorax
import datetime
import os
import pandas as pd<jupyter_output><empty_output><jupyter_text>Create ephemeris records to demonstrate deleting them<jupyter_code># read API key from environment vars
api_key = os.environ["AURORAX_API_KEY"]
pyaurorax.authenticate(api_key)

# set values
program = "notebook-program"
platform = "notebook-platform"
instrument_type = "notebook-instrument-type"
metadata = {
    "test_meta1": "testing1",
    "test_meta2": "testing2",
}
epoch = datetime.datetime(2020, 1, 1, 0, 0)
location_geo = pyaurorax.Location(lat=51.049999, lon=-114.066666)
location_gsm = pyaurorax.Location(lat=150.25, lon=-10.75)
nbtrace = pyaurorax.Location(lat=1.23, lon=45.6)
sbtrace = pyaurorax.Location(lat=7.89, lon=101.23)

# get the ephemeris source ID
source = pyaurorax.sources.get(program, platform, instrument_type)

# create Ephemeris objects
e = pyaurorax.ephemeris.Ephemeris(data_source=source,
                                epoch=epoch,
                                location_geo=location_geo,
                                location_gsm=location_gsm,
                                nbtrace=nbtrace,
                                sbtrace=sbtrace,
                                metadata=metadata)

epoch2 = datetime.datetime(2020, 1, 1, 0, 1)
metadata2 = {
    "test_meta1": "testing12",
    "test_meta2": "testing22",
}
e2 = pyaurorax.ephemeris.Ephemeris(data_source=source,
                                epoch=epoch2,
                                location_geo=location_geo,
                                location_gsm=location_gsm,
                                nbtrace=nbtrace,
                                sbtrace=sbtrace,
                                metadata=metadata2)

# set records array
records = [e, e2]

# upload records
pyaurorax.ephemeris.upload(source.identifier, records, True)


# retrieve uploaded record
s = pyaurorax.ephemeris.search(datetime.datetime(2020, 1, 1, 0, 0, 0),
                             datetime.datetime(2020, 1, 1, 23, 59, 59),
                             programs=["notebook-program"],
                             platforms=["notebook-platform"],
                             instrument_types=["notebook-instrument-type"])

# show data as a pandas dataframe
ephemeris_data = [e.__dict__ for e in s.data]
df = pd.DataFrame(ephemeris_data)
df<jupyter_output><empty_output><jupyter_text>Delete ephemeris records<jupyter_code># delete records
pyaurorax.ephemeris.delete(source, datetime.datetime(
    2020, 1, 1, 0, 0, 0), datetime.datetime(2020, 1, 1, 23, 59, 59))

# search ephemeris again to see that they were deleted
s = pyaurorax.ephemeris.search(datetime.datetime(2020, 1, 1, 0, 0, 0),
                             datetime.datetime(2020, 1, 1, 23, 59, 59),
                             programs=["notebook-program"],
                             platforms=["notebook-platform"],
                             instrument_types=["notebook-instrument-type"])

if len(s.data) == 0:
    print("Data was deleted")
else:
    print("Data was not deleted")<jupyter_output>Data was deleted
{'fraction_non_alphanumeric': 0.10492642354446577, 'fraction_numerical': 0.04350607805502239, 'mean_word_length': 2.33013844515442, 'pattern_counts': {'":': 4, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '185659', 'license': 'MIT', 'n_tokens_mistral': 1083, 'n_tokens_neox': 964, 'n_words': 196, 'path': 'examples/notebooks/delete_ephemeris.ipynb', 'repo_name': 'ucalgary-aurora/pyaurorax', 'size': '3126'}