#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Paresh Prema 23 Apr 2020 """ USAGE NOTES - Fields in the notes below marked with an * are required. - Notes about the fields, their options, other "desig"*: e.g. "C0JKKQ2" "observer"*: Name of Person Reporting Cometary Activity - e.g. Format "P. Prema" or "P. Prema, D. Bell" for multiple observers "email"*: e.g. "pprema@cfa.harvard.edu" "obsdate"*: Format required - YYYY-MM-DD e.g "2020-01-09" "obstime": Format required HH-MM-SS e.g. "12:52:56" "obscode"*: e.g "K19" "aperture"*: Unit in Meters (m) "is_comet"*: Options are: ['T', 'P', 'F'] - 'T' = Defintely Cometary - 'P' = Possibly Cometary - 'F' = Not Cometary "coma_appearance"*: Option are: ['no coma', 'very condensed', 'condensed', 'diffuse', 'very diffuse'] "coma_diam"*: Units chosen below "coma_diam_units"*: Options are: ['arc_sec', 'arc_min', 'arc_deg'] - 'arc_sec' = arc seconds - 'arc_min' = arc minutes - 'arc_deg' = degrees "tail_appearance"*: Options are: ['no tail', 'straight', 'broad', 'curved'] - 'no tail' = No Tail - 'straight' = Straight - 'broad' = Broad - 'curved' = Curved "tail_length"*: Unit chosen below "tail_length_units"*: Options are: ['arc_sec', 'arc_min', 'arc_deg'] - 'arc_sec' = arc seconds - 'arc_min' = arc minutes - 'arc_deg' = degrees "tail_pa"*: Units in degrees - Tail Position angle - The lower bound of the broad tail "tail_pa2": Units in degrees - Tail Position angle - The upper bound of the broad tail "additional_comments": "MPC Testing" """ import requests import json comet_submissions_url = 'https://minorplanetcenter.net/mpcops/submissions/cometary/' # Example JSON to send # Cometary all fields used cometary_all = { "desig": "C0JKKQ2", "observer": "P. Prema", "email": "pprema@cfa.harvard.edu", "obsdate": "2020-04-23", "obstime": "12:52:56", "obscode": "310", "aperture": "6", "is_comet": "P", "coma_appearance": "condensed", "coma_diam": "3", "coma_diam_units": "arc_sec", "tail_appearance": "straight", "tail_length": "10", "tail_length_units": "arc_sec", "tail_pa": "42", "tail_pa2": "", "additional_comments": "MPC testing" } params = cometary_all # The payload/params etc can be passed simply using 'json=' in the # POST request. No need to specify headers identifying types # json=params - send json data # data=params send get or post depending on what you specify: # e.g. requests.post # requests.get response = requests.get(comet_submissions_url,json=params) # User is able to check status e.g. print (response.status_code, response.reason) # Further reponse methods can be found here for example # https://2.python-requests.org/en/stable/api/#requests.Response # Get JSON data using the command below print (response.text)