astroquery icon indicating copy to clipboard operation
astroquery copied to clipboard

can't suppress warnings astroquery and astrometry.net

Open dts350z opened this issue 6 years ago • 9 comments

command line or top of code suppression of warnings still emits:

gzip was not found on your system! You should solve this issue for astroquery.eso to be at its best! On POSIX system: make sure gzip is installed and in your path!On Windows: same for 7-zip (http://www.7-zip.org)! WARNING: Astrometry.net API key not found in configuration file [astroquery.astrometry_net.core] WARNING: You need to manually edit the configuration file and add it [astroquery.astrometry_net.core] WARNING: You may also register it for this session with AstrometryNet.key = 'XXXXXXXX' [astroquery.astrometry_net.core] WARNING: Astrometry.net API key not found in configuration file [astroquery.astrometry_net.core] WARNING: You need to manually edit the configuration file and add it [astroquery.astrometry_net.core] WARNING: You may also register it for this session with AstrometryNet.key = 'XXXXXXXX' [astroquery.astrometry_net.core]

Top of code:

import warnings warnings.filterwarnings(action="ignore") from astroquery.astrometry_net import AstrometryNet import astropy.wcs as wcs import re import math from PIL import Image, ImageOps import os import sys ast = AstrometryNet() ast.api_key = 'azomzzzzzzzzzz' <-- not real key

dts350z avatar Sep 01 '19 00:09 dts350z

I guess I'm also stuck lacking completion of this TODO in the documentation:

"TODO: explain how to set config item for api key or how to get it into keyring."

dts350z avatar Sep 01 '19 19:09 dts350z

cc @mwcraig - are these log.warnings instead of warning.warns?

keflavich avatar Sep 05 '19 01:09 keflavich

are these log.warnings instead of warning.warns?

Yes; I gather they should be the latter?

mwcraig avatar Sep 05 '19 02:09 mwcraig

Is there any update as to when/if this will be fixed? It's bites me in the but all the time in astropy 4.0, but I'd be happy to update to a later version if its fixed.

Or even make the changes, if its pretty trivial.

DaveStrickland avatar May 22 '21 12:05 DaveStrickland

@DaveStrickland the easiest thing to do might be

from astropy import log
log.setLevel('ERROR')
from astroquery.astrometry_net import AstrometryNet

That will suppress this warning.

Alternatively, you can set up the configuration to include an API key.

This isn't a bug, though - the warning is intentional because the astrometry_net module requires an API key to function.

keflavich avatar May 22 '21 18:05 keflavich

Hi @keflavich, I was imprecise in my comment, as I was really wondering about whether the message was going to be moved over to use the warnings system and I didn't want to mess with the log levels as I rely on DEBUG level logging for a variety of things.

However your suggestion does work, as I just realized I can just reset the log level immediately after the from astroquery.astrometry_net import AstrometryNet statement.

So problem solved, and thanks!

DaveStrickland avatar May 23 '21 18:05 DaveStrickland

Great, I'm glad that workaround works!

I don't think we want to move to the generic warning system for this, but I don't have a particularly strong argument - if there are good arguments either way, please voice them!

keflavich avatar May 23 '21 18:05 keflavich

I am on Ubuntu 21.04 server. Where is the configuration file astroquery.astrometry_net.core ?? Thanks

CAReeser avatar Dec 15 '21 19:12 CAReeser

@DaveStrickland the easiest thing to do might be

from astropy import log log.setLevel('ERROR') from astroquery.astrometry_net import AstrometryNet

Typo here, should be

from astroquery import log

Works tho. Thanks

rankinstudio avatar Oct 22 '25 01:10 rankinstudio