{"action":"closed","issue":{"url":"https://api.github.com/repos/desihub/desisim/issues/451","repository_url":"https://api.github.com/repos/desihub/desisim","labels_url":"https://api.github.com/repos/desihub/desisim/issues/451/labels{/name}","comments_url":"https://api.github.com/repos/desihub/desisim/issues/451/comments","events_url":"https://api.github.com/repos/desihub/desisim/issues/451/events","html_url":"https://github.com/desihub/desisim/issues/451","id":382445878,"node_id":"MDU6SXNzdWUzODI0NDU4Nzg=","number":451,"title":"`BRICKNAME` doesn't exist in `quickspectra` output","user":{"login":"londumas","id":3166436,"node_id":"MDQ6VXNlcjMxNjY0MzY=","avatar_url":"https://avatars0.githubusercontent.com/u/3166436?v=4","gravatar_id":"","url":"https://api.github.com/users/londumas","html_url":"https://github.com/londumas","followers_url":"https://api.github.com/users/londumas/followers","following_url":"https://api.github.com/users/londumas/following{/other_user}","gists_url":"https://api.github.com/users/londumas/gists{/gist_id}","starred_url":"https://api.github.com/users/londumas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/londumas/subscriptions","organizations_url":"https://api.github.com/users/londumas/orgs","repos_url":"https://api.github.com/users/londumas/repos","events_url":"https://api.github.com/users/londumas/events{/privacy}","received_events_url":"https://api.github.com/users/londumas/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-11-20T00:14:59Z","updated_at":"2018-11-20T04:50:04Z","closed_at":"2018-11-20T04:50:03Z","author_association":"CONTRIBUTOR","body":"I create a fake quasar using `desisim.templates.QSO()`, then I expand it with `quickspectra` and I fit it using `redrock`.\r\nThe code used to work, but it doesn't anymore on master. Do you know why `BRICKNAME` can't be found in the output file of `quickspectra`?\r\n\r\nThe error:\r\n\r\n```\r\n<me>@edison04:~/Run_programs/desi/redrock/Look_velocity_dispersion_redshift_fitting> rrdesi /scratch1/scratchdirs/<me>/desi/SIMQSO/master_10_again/qso-observed-spectra.fits --output /scratch1/scratchdirs/<me>/desi/SIMQSO/master_10_again/qso-rrdetail.h5 --zbest /scratch1/scratchdirs/<me>/desi/SIMQSO/master_10_again/qso-zbest.fits --archetypes $HOME/Programs/desi/code/redrock/py/redrock/archetypes/\r\nRunning on a NERSC login node- reducing number of processes to 4\r\nRunning with 4 processes\r\nLoading targets...\r\nProc 0: Traceback (most recent call last):\r\nProc 0:   File \"/global/homes/h/<me>/Programs/desi/code/redrock/py/redrock/external/desi.py\", line 600, in rrdesi\r\n    comm=comm, cache_Rcsr=True, cosmics_nsig=args.cosmics_nsig)\r\nProc 0:   File \"/global/homes/h/<me>/Programs/desi/code/redrock/py/redrock/external/desi.py\", line 289, in __init__\r\n    bname = frow[\"BRICKNAME\"]\r\nProc 0:   File \"/global/common/software/desi/edison/desiconda/20180709-1.2.6-spec/conda/lib/python3.6/site-packages/astropy/table/row.py\", line 46, in __getitem__\r\n    return self._table.columns[item][self._index]\r\nProc 0:   File \"/global/common/software/desi/edison/desiconda/20180709-1.2.6-spec/conda/lib/python3.6/site-packages/astropy/table/table.py\", line 109, in __getitem__\r\n    return OrderedDict.__getitem__(self, item)\r\nProc 0: KeyError: 'BRICKNAME'\r\n\r\nTotal run time: 0.2 seconds\r\n```\r\n\r\nThe code:\r\n\r\n```\r\nimport os\r\nimport subprocess\r\nimport matplotlib.pyplot as plt\r\n\r\nimport scipy as sp\r\nimport numpy.random\r\nimport scipy.constants\r\n\r\nimport astropy.io.fits as pyfits\r\nfrom astropy.table import Table\r\n\r\nimport desispec.io\r\nimport desisim.io\r\nimport desisim.templates\r\n\r\n\r\nobj = \"qso\"\r\nsimdir = os.getenv('SCRATCH') + '/desi/SIMQSO/master_10_again/'\r\nspecoutfile = simdir + obj +'-observed-spectra.fits'\r\nzoutfile    = simdir + obj +'-zbest.fits'\r\nsoutfile    = simdir + obj +'-rrdetail.h5'\r\nsaveZTrue   = simdir + obj +'-ztrue.txt'\r\n\r\n\r\ndef create_spectra():\r\n\r\n    nbObj = 1\r\n    sp.random.seed(42)\r\n\r\n    ### Create some spectra\r\n    qso_maker = desisim.templates.QSO()\r\n    flux, wave, meta, objmeta = qso_maker.make_templates(nmodel=nbObj,seed=42,lyaforest=True)\r\n    #sp.savetxt(saveZTrue,meta['REDSHIFT'])\r\n\r\n    ### Store them\r\n    os.makedirs(simdir, exist_ok=True)\r\n    infile = simdir + '/'+obj+'-input-spectra.fits'\r\n    hdr = pyfits.Header()\r\n    hdr['EXTNAME'] = 'WAVELENGTH'\r\n    hdr['BUNIT'] = 'Angstrom'\r\n    pyfits.writeto(infile, wave, header=hdr, overwrite=True)\r\n    hdr['EXTNAME'] = 'FLUX'\r\n    hdr['BUNIT'] = '10^-17 ergs/s/cm2/A'\r\n    pyfits.append(infile, flux, header=hdr)\r\n    hdr['EXTNAME'] = 'REDSHIFT'\r\n    pyfits.append(infile, meta['REDSHIFT'], header=hdr)\r\n    \r\n    ### Apply DESI spect\r\n    cmd  = ' quickspectra --input ' + infile\r\n    cmd += ' --out-spectra ' + specoutfile\r\n    cmd += ' --seeing 0.6'\r\n    cmd += ' --exptime 1000'  ### Here is the exposure time\r\n    cmd += ' --seed 42'\r\n    cmd += ' --source-type '+obj\r\n    print(cmd)\r\n    #cmd = 'srun --time 30 --qos debug '+cmd\r\n    subprocess.call(cmd, shell=True)\r\n\r\n    ### Send redrock\r\n    cmd  = ' rrdesi_mpi ' + specoutfile\r\n    cmd += ' --output ' + soutfile\r\n    cmd += ' --zbest ' + zoutfile\r\n    cmd += ' --archetypes $HOME/Programs/desi/code/redrock/py/redrock/archetypes/'\r\n    print(cmd)\r\n    #cmd = 'srun --time 30 --qos debug '+cmd\r\n    #srun = 'srun -A desi -N 1 -t 00:10:00 -C haswell --qos interactive'\r\n    #cmd = '{srun} {cmd} --ncpu 32'.format(srun=srun, cmd=cmd)\r\n    subprocess.call(cmd, shell=True)\r\n\r\n    return\r\n\r\ncreate_spectra()\r\n\r\n```"}}
{"actor":{"display_login":"sbailey"}}