def Main(
    SuperNovaId=None,
    ResultFormat=None,
    CheckArguments=True,
    PrintExtra=False,
):

    Result = None

    if (CheckArguments):
        ArgumentErrorMessage = ""

        if (len(ArgumentErrorMessage) > 0):
            if (PrintExtra):
                print("ArgumentErrorMessage:\n", ArgumentErrorMessage)
            raise Exception(ArgumentErrorMessage)

    #Example:
    #https://sne.space/astrocats/astrocats/supernovae/output/json/SNLS-03D1ax.json

    OpenSuperNovaCatalogId = "SNLS-" + SuperNovaId

    Url = "https://sne.space/astrocats/astrocats/supernovae/output/json/" + OpenSuperNovaCatalogId + ".json"
    SuperNovaDataJson = Library_HttpGetShared.Main(Url=Url, )
    SuperNovaDataNestedObject = Library_JsonLoad.Main(
        JsonString=SuperNovaDataJson,
        ForceAscii=True,
    )
    print('SuperNovaDataNestedObject',
          SuperNovaDataNestedObject['SNLS-03D1ax'].keys())

    PhotometryUrl = "https://api.astrocats.space/" + OpenSuperNovaCatalogId + "/photometry/magnitude+e_magnitude+band+time"
    PhotometrySuperNovaDataJson = Library_HttpGetShared.Main(
        Url=PhotometryUrl, )
    PhotometrySuperNovaDataNestedObject = Library_JsonLoad.Main(
        JsonString=PhotometrySuperNovaDataJson,
        ForceAscii=True,
    )
    print('PhotometrySuperNovaDataNestedObject',
          PhotometrySuperNovaDataNestedObject['SNLS-03D1ax'].keys())

    if ResultFormat is None:
        Result = SuperNovaDataNestedObject
    elif ResultFormat == 'PhotometryOnly':
        Result = PhotometrySuperNovaDataNestedObject

    return Result
Пример #2
0
def Search_by_Te_metal_acqusiition_date(first, second, third, fourth, fifth,
                                        sixth):
    def convert(data):
        if isinstance(data, basestring):
            return str(data)
        elif isinstance(data, bson.objectid.ObjectId):
            return str(data)
        elif isinstance(data, collections.Mapping):
            return dict(map(convert, data.iteritems()))
        elif isinstance(data, collections.Iterable):
            return type(data)(map(convert, data))
        else:
            return data

    FullObject = []

    for Year in range(first, second):
        for Month in range(third, fourth):
            for Day in range(fifth, sixth):
                DateString = str(Year) + '-' + str(Month) + '-' + str(Day)

                for Te_metal_acqusiiton_date in db.sandbox.find(
                    {"Te_metal_acqusiiton_date": DateString}):
                    Te_metal_acqusiiton_datejsonOK = convert(
                        Te_metal_acqusiiton_date)

                    FullObject.append(Te_metal_acqusiiton_datejsonOK)

    FullObjectAsString = json.dumps(FullObject, indent=4)

    FileHandle = open(
        'json_files/Crystals_found_by_Te_Metal_Acqusiition_Date.json', 'w')
    FileHandle.write(FullObjectAsString)
    FileHandle.close()

    FileHandle = open(
        'json_files/Crystals_found_by_Te_Metal_Acqusiition_Date.json', 'r')
    FullObjectAsStringFromFile = FileHandle.read()
    FileHandle.close()

    FullObjectFromFile = Library_JsonLoad.Main(
        FullObjectAsStringFromFile,
        ForceAscii=True,
    )


#Search_by_Te_metal_acqusiition_date(first,second,third,fourth,fifth,sixth)
Пример #3
0
def Search_by_Crystals_Te_acq_to_Xtal_storage(Number_of_Days):
    def convert(data):
        if isinstance(data, basestring):
            return str(data)
        elif isinstance(data, bson.objectid.ObjectId):
            return str(data)
        elif isinstance(data, collections.Mapping):
            return dict(map(convert, data.iteritems()))
        elif isinstance(data, collections.Iterable):
            return type(data)(map(convert, data))
        else:
            return data

    FullObject = []
    Day = str(Number_of_Days)

    for Days in range(Number_of_Days):
        for Te_aqc_to_Xtal_storage in db.sandbox.find(
            {"Te_aqc_to_Xtal_storage": Day}):
            Te_aqc_to_Xtal_storagejsonOK = convert(Te_aqc_to_Xtal_storage)

            FullObject.append(Te_aqc_to_Xtal_storagejsonOK)

    FullObjectAsString = json.dumps(FullObject, indent=4)

    FileHandle = open(
        'json_files/Crystals_found_by_Te_aqc_to_Xtal_storage.json', 'w')
    FileHandle.write(FullObjectAsString)
    FileHandle.close()

    FileHandle = open(
        'json_files/Crystals_found_by_Te_aqc_to_Xtal_storage.json', 'r')
    FullObjectAsStringFromFile = FileHandle.read()
    FileHandle.close()

    FullObjectFromFile = Library_JsonLoad.Main(
        FullObjectAsStringFromFile,
        ForceAscii=True,
    )


#Search_by_Crystals_Te_acq_to_Xtal_storage(Number_of_Days)
def Main(
    FilePath=None,
    CheckArguments=True,
    PrintExtra=False,
):

    Result = None

    if (CheckArguments):
        ArgumentErrorMessage = ""

        if (len(ArgumentErrorMessage) > 0):
            if (PrintExtra):
                print("ArgumentErrorMessage:\n", ArgumentErrorMessage)
            raise Exception(ArgumentErrorMessage)

    #Read in the contents of the original file into a python object:
    OriginalContents = Library_FileReadAsText.Main(FilePath)
    NestedObject = Library_JsonLoad.Main(OriginalContents)

    Result = NestedObject
    return Result
Пример #5
0
def Search_by_Crystals_Te_batch(Number_of_Te_batch):
	def convert(data):
		if isinstance(data, basestring):
			return str(data)
		elif isinstance(data, bson.objectid.ObjectId): 
			return str(data)
		elif isinstance(data, collections.Mapping):
			return dict(map(convert, data.iteritems()))
		elif isinstance(data, collections.Iterable):
			return type(data)(map(convert, data))
		else:
			return data 

	FullObject = []
	batch = str(Te_batch)

	for Te_batch in db.sandbox.find({"Te_batch": batch}):
		Te_batchjsonOK = convert(Te_batch)
	
		FullObject.append(Te_batchjsonOK)

	FullObjectAsString = json.dumps( FullObject , indent=4) 
     
	FileHandle = open('json_files/Crystals_found_by_Te_batch.json', 'w')
	FileHandle.write(FullObjectAsString)
	FileHandle.close()

	FileHandle = open('json_files/Crystals_found_by_Te_batch.json', 'r')
	FullObjectAsStringFromFile = FileHandle.read()
	FileHandle.close()

	FullObjectFromFile = Library_JsonLoad.Main(
		FullObjectAsStringFromFile,
		ForceAscii = True,
	)

#Search_by_Crystals_life_in_cavern(Number_of_Days)
Пример #6
0
						if comments_4 != "CUORE-0":
							age_d = convert(age_4)
							FullObject.append(age_d)
					
FullObjectAsString = json.dumps( FullObject , indent=4) 

FileHandle = open('Loca.json', 'w')
FileHandle.write(FullObjectAsString)
FileHandle.close()

FileHandle = open('Loca.json', 'r')
FullObjectAsStringFromFile = FileHandle.read()
FileHandle.close()

FullObjectFromFile = Library_JsonLoad.Main(
	FullObjectAsStringFromFile,
	ForceAscii = True,
)  
 
All_Items = [] 
for Sally in FullObjectFromFile: 
	value_of_intrest = Sally["Xtal_current_age"] 
        if value_of_intrest != "NAN": 
                All_Items.append(value_of_intrest)
 
 
 
 

Hal9000 = map(int, All_Items)

def Main(
    RightAscension=None,
    Declination=None,
    Radius=None,  #In arc seconds
    CheckArguments=True,
    PrintExtra=False,
):

    Result = None

    if (CheckArguments):
        ArgumentErrorMessage = ""

        if (len(ArgumentErrorMessage) > 0):
            if (PrintExtra):
                print("ArgumentErrorMessage:\n", ArgumentErrorMessage)
            raise Exception(ArgumentErrorMessage)

    #Convert the degrees to the min, sec, arcsec
    AstropySkyCoordinateObject = astropy.coordinates.SkyCoord(
        ra=RightAscension * astropy.units.degree,
        dec=Declination * astropy.units.degree,
        frame='icrs',  #Double check this
        unit='deg',
    )

    TimeCoordinates = AstropySkyCoordinateObject.to_string('hmsdms')
    print('TimeCoordinates', TimeCoordinates)
    #RaTimeCoords = TimeCoordinates[0]
    #DecTimeCoords = TimeCoordinates[1]

    #RaTimeCoords = str(RightAscension)
    #DecTimeCoords = str(Declination)

    Ra_hh = TimeCoordinates.split(' ')[0].split('h')[0]
    print('Ra_hh', Ra_hh)
    Ra_mm = TimeCoordinates.split(' ')[0].split('m')[0].split('h')[1]
    print('Ra_mm', Ra_mm)
    Ra_ss = TimeCoordinates.split(' ')[0].split('s')[0].split('m')[1]
    print('Ra_ss', Ra_ss)
    RaTimeCoords = Ra_hh + ':' + Ra_mm + ':' + Ra_ss
    print('RaTimeCoords', RaTimeCoords)

    Dec_dd = TimeCoordinates.split(' ')[1].split('d')[0]
    print('Dec_dd', Dec_dd)
    Dec_mm = TimeCoordinates.split(' ')[1].split('m')[0].split('d')[1]
    print('Dec_mm', Dec_mm)
    Dec_ss = TimeCoordinates.split(' ')[1].split('s')[0].split('m')[1]
    print('Dec_ss', Dec_ss)
    DecTimeCoords = Dec_dd + ':' + Dec_mm + ':' + Dec_ss
    print('DecTimeCoords', DecTimeCoords)

    #Example Data Search:
    # https://api.astrocats.space/catalog?ra=21:23:32.16&dec=-53:01:36.08&radius=2
    Url = "https://api.astrocats.space/catalog?ra=" + RaTimeCoords + "&dec=" + DecTimeCoords + "&radius=" + str(
        Radius)
    SuperNovaDataJson = Library_HttpGetShared.Main(Url=Url, )
    SuperNovaDataNestedObject = Library_JsonLoad.Main(
        JsonString=SuperNovaDataJson,
        ForceAscii=True,
    )

    Result = SuperNovaDataNestedObject

    return Result