简体   繁体   中英

Appending an array with matching catalogs

so what I am trying to accomplish is creating a loop which appends an array based on matching SpecObjIDS, and appends the stellar masses from their respective arrays "VESPA_ID_SM_Array[:,1]" , "Celestial_Matrix[:,4]"

VESPA_ID_SM_Array=np.array(np.genfromtxt('C:\\Python12\\Vespa_SM.csv\\results13_19_37_44_33.csv', delimiter=','))

^This file contains 2 columns. The first column contains a "SpecObjID" for the VESPA catalog, and the second column contains the stellar mass values for each ID.

SpecObjID=SpecObj_Table.field(47) contains one column which is the "SpecObjID" for the Sloan Digital Sky Survey Catalog.

NOTE: The SpecObjID for the VESPA catalog is THE SAME as the SpecObjID for the SDSS catalog.

"Celestial_Matrix[:,4]" is an array I previously created, and the 5th column contains the stellar mass of select galaxies from the SDSS survey.

The code that I wrote in an attempt to do this is:

SDSS_VESPA_SM=[]
for idy, y in SpecObjID:
    for idy, y in enumerate(VESPA_ID_SM_Array[:,0]):
        if SpecObjID[idy] == VESPA_ID_SM_Array[:,0][idy]:
            SDSS_VESPA_SM.append([[idy],y , Celestial_Matrix[:,4][idy] ,VESPA_ID_SM_Array[:,1][idy]])

The error I get when running this is "'numpy.int64' object is not iterable " Thank you in advance for everyone's time and help.

An is not iterable error can be raised when you try to destructure a scalar value. For example:

>>> x, y = 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable

In this case it looks like the culprit is for idy, y in SpecObjID . Each item you're looping over looks like a scalar which you're trying to unpack into idy, y .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM