can't suppress warnings astroquery and astrometry.net
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
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."
cc @mwcraig - are these log.warnings instead of warning.warns?
are these log.warnings instead of warning.warns?
Yes; I gather they should be the latter?
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 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.
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!
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!
I am on Ubuntu 21.04 server. Where is the configuration file astroquery.astrometry_net.core ?? Thanks
@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