diff --git a/goodman_focus/goodman_focus.py b/goodman_focus/goodman_focus.py
index f975ec9..04523bc 100644
--- a/goodman_focus/goodman_focus.py
+++ b/goodman_focus/goodman_focus.py
@@ -102,9 +102,12 @@ def get_args(arguments=None):
     args = parser.parse_args(args=arguments)
 
     if not os.path.isdir(args.data_path):
-        parser.error("Data location {} does not exist".format(args.data_path))
+        log.error("Data location {} does not exist".format(args.data_path))
+        sys.exit(0)
     elif len(glob.glob(os.path.join(args.data_path, args.file_pattern))) == 0:
-        parser.error("There are no files matching \"{}\" in the folder \"{}\"".format(args.file_pattern, args.data_path))
+        log.error("There are no files matching \"{}\" in the folder \"{}\""
+                  "".format(args.file_pattern, args.data_path))
+        sys.exit(0)
 
     return args
 
@@ -325,32 +328,45 @@ class GoodmanFocus(object):
         _ifc = ImageFileCollection(self.full_path, keywords=self.keywords)
 
         self.ifc = _ifc.summary.to_pandas()
+        self.log.debug("Found {} FITS files".format(self.ifc.shape[0]))
         self.ifc = self.ifc[(self.ifc['OBSTYPE'] == self.args.obstype)]
-        self.focus_groups = []
-        configs = self.ifc.groupby(['CAM_TARG',
-                                    'GRT_TARG',
-                                    'FILTER',
-                                    'FILTER2',
-                                    'GRATING',
-                                    'SLIT',
-                                    'WAVMODE',
-                                    'RDNOISE',
-                                    'GAIN',
-                                    'ROI']).size().reset_index().rename(
-            columns={0: 'count'})
-        # print(configs.to_string())
-        for i in configs.index:
-            focus_group = self.ifc[((self.ifc['CAM_TARG'] == configs.iloc[i]['CAM_TARG']) &
-                                    (self.ifc['GRT_TARG'] == configs.iloc[i]['GRT_TARG']) &
-                                    (self.ifc['FILTER'] == configs.iloc[i]['FILTER']) &
-                                    (self.ifc['FILTER2'] == configs.iloc[i]['FILTER2']) &
-                                    (self.ifc['GRATING'] == configs.iloc[i]['GRATING']) &
-                                    (self.ifc['SLIT'] == configs.iloc[i]['SLIT']) &
-                                    (self.ifc['WAVMODE'] == configs.iloc[i]['WAVMODE']) &
-                                    (self.ifc['RDNOISE'] == configs.iloc[i]['RDNOISE']) &
-                                    (self.ifc['GAIN'] == configs.iloc[i]['GAIN']) &
-                                    (self.ifc['ROI'] == configs.iloc[i]['ROI']))]
-            self.focus_groups.append(focus_group)
+        if self.ifc.shape[0] != 0:
+            self.log.debug("Found {} FITS files with OBSTYPE = FOCUS".format(
+                self.ifc.shape[0]))
+
+            self.focus_groups = []
+            configs = self.ifc.groupby(['CAM_TARG',
+                                        'GRT_TARG',
+                                        'FILTER',
+                                        'FILTER2',
+                                        'GRATING',
+                                        'SLIT',
+                                        'WAVMODE',
+                                        'RDNOISE',
+                                        'GAIN',
+                                        'ROI']).size().reset_index().rename(
+                columns={0: 'count'})
+            # print(configs.to_string())
+            for i in configs.index:
+                focus_group = self.ifc[((self.ifc['CAM_TARG'] == configs.iloc[i]['CAM_TARG']) &
+                                        (self.ifc['GRT_TARG'] == configs.iloc[i]['GRT_TARG']) &
+                                        (self.ifc['FILTER'] == configs.iloc[i]['FILTER']) &
+                                        (self.ifc['FILTER2'] == configs.iloc[i]['FILTER2']) &
+                                        (self.ifc['GRATING'] == configs.iloc[i]['GRATING']) &
+                                        (self.ifc['SLIT'] == configs.iloc[i]['SLIT']) &
+                                        (self.ifc['WAVMODE'] == configs.iloc[i]['WAVMODE']) &
+                                        (self.ifc['RDNOISE'] == configs.iloc[i]['RDNOISE']) &
+                                        (self.ifc['GAIN'] == configs.iloc[i]['GAIN']) &
+                                        (self.ifc['ROI'] == configs.iloc[i]['ROI']))]
+                self.focus_groups.append(focus_group)
+        else:
+            self.log.critical('Focus files must have OBSTYPE keyword equal to '
+                              '"FOCUS", none found.')
+            self.log.info('Please use "--obstype" to change the value though '
+                          'it is not recommended to use neither "OBJECT" nor '
+                          '"FLAT" because it may contaminate the sample with '
+                          'non focus images.')
+            sys.exit(0)
 
     @property
     def fwhm(self):

Add log report when no files are found
For older data the keyword OBSTYPE does not contain the vale FOCUS which causes the program to exit without doing anything and without any error messages.
diff --git a/goodman_focus/tests/test_goodman_focus.py b/goodman_focus/tests/test_goodman_focus.py
index e06ba7d..73c162b 100644
--- a/goodman_focus/tests/test_goodman_focus.py
+++ b/goodman_focus/tests/test_goodman_focus.py
@@ -166,3 +166,56 @@ class GoodmanFocusTests(TestCase):
     def tearDown(self):
         for _file in self.file_list:
             os.unlink(_file)
+
+
+class DirectoryAndFilesTest(TestCase):
+
+    def setUp(self):
+        self.arguments = [
+            '--data-path', os.path.join(os.getcwd(), 'nonexisting'),
+            '--file-pattern', '*.fits',
+            '--obstype', 'FOCUS',
+            '--features-model', 'gaussian']
+
+        os.mkdir(os.path.join(os.getcwd(), 'test_dir_empty'))
+        os.mkdir(os.path.join(os.getcwd(), 'test_dir_no_focus'))
+        for i in range(3):
+            ccd = CCDData(data=np.ones((100, 100)),
+                          meta=fits.Header(),
+                          unit='adu')
+            ccd.header['obstype'] = 'OBJECT'
+            ccd.header['cam_foc'] = 0
+            ccd.header['cam_targ'] = 0
+            ccd.header['grt_targ'] = 0
+            ccd.header['filter'] = 'filter'
+            ccd.header['filter2'] = 'filter2'
+            ccd.header['grating'] = 'grating'
+            ccd.header['slit'] = '0.4 slit'
+            ccd.header['wavmode'] = '400m2'
+            ccd.header['rdnoise'] = 1
+            ccd.header['gain'] = 1
+            ccd.header['roi'] = 'user-defined'
+
+            ccd.write(os.path.join(os.getcwd(),
+                                   'test_dir_no_focus',
+                                   'file_{}.fits'.format(i+1)))
+
+    def test_directory_does_not_exists(self):
+
+        # goodman_focus = GoodmanFocus(arguments=arguments)
+        self.assertRaises(SystemExit, GoodmanFocus, self.arguments)
+
+    def test_directory_exists_but_empty(self):
+        self.arguments[1] = os.path.join(os.getcwd(), 'test_dir_empty')
+        self.assertRaises(SystemExit, GoodmanFocus, self.arguments)
+
+    def test_no_focus_files(self):
+        self.arguments[1] = os.path.join(os.getcwd(), 'test_dir_no_focus')
+        self.assertRaises(SystemExit, GoodmanFocus, self.arguments)
+
+
+    def tearDown(self):
+        os.rmdir(os.path.join(os.getcwd(), 'test_dir_empty'))
+        for _file in os.listdir(os.path.join(os.getcwd(), 'test_dir_no_focus')):
+            os.unlink(os.path.join(os.getcwd(), 'test_dir_no_focus', _file))
+        os.rmdir(os.path.join(os.getcwd(), 'test_dir_no_focus'))

environment.yml
pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
astropy==3.2.1
astropy-healpix==0.6
astroscrappy==1.1.0
attrs==22.2.0
Babel==2.11.0
ccdproc==1.3.0.post1
certifi==2021.5.30
charset-normalizer==2.0.12
cycler==0.11.0
decorator==4.4.2
docutils==0.18.1
-e git+https://github.com/soar-telescope/goodman_focus.git@aae2c512526bd89c760a61f834154079e46809ed#egg=goodman_focus
idna==3.10
imageio==2.15.0
imagesize==1.4.1
importlib-metadata==4.8.3
iniconfig==1.1.1
Jinja2==3.0.3
kiwisolver==1.3.1
MarkupSafe==2.0.1
matplotlib==3.1.0
networkx==2.5.1
numpy==1.16.4
packaging==21.3
pandas==0.24.2
Pillow==8.4.0
pluggy==1.0.0
py==1.11.0
Pygments==2.14.0
pyparsing==3.1.4
pytest==7.0.1
python-dateutil==2.9.0.post0
pytz==2025.2
PyWavelets==1.1.1
reproject==0.7.1
requests==2.27.1
scikit-image==0.17.2
scipy==1.3.0
six==1.17.0
snowballstemmer==2.2.0
Sphinx==2.1.2
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tifffile==2020.9.3
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
zipp==3.6.0

name: goodman_focus
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - astropy==3.2.1
      - astropy-healpix==0.6
      - astroscrappy==1.1.0
      - attrs==22.2.0
      - babel==2.11.0
      - ccdproc==1.3.0.post1
      - charset-normalizer==2.0.12
      - cycler==0.11.0
      - decorator==4.4.2
      - docutils==0.18.1
      - idna==3.10
      - imageio==2.15.0
      - imagesize==1.4.1
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - jinja2==3.0.3
      - kiwisolver==1.3.1
      - markupsafe==2.0.1
      - matplotlib==3.1.0
      - networkx==2.5.1
      - numpy==1.16.4
      - packaging==21.3
      - pandas==0.24.2
      - pillow==8.4.0
      - pluggy==1.0.0
      - py==1.11.0
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pywavelets==1.1.1
      - reproject==0.7.1
      - requests==2.27.1
      - scikit-image==0.17.2
      - scipy==1.3.0
      - setuptools==40.2.0
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==2.1.2
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - tifffile==2020.9.3
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - zipp==3.6.0
prefix: /opt/conda/envs/goodman_focus

goodman_focus/tests/test_goodman_focus.py::DirectoryAndFilesTest::test_no_focus_files
goodman_focus/tests/test_goodman_focus.py::GetPeaksTest::test_multiple_peaks goodman_focus/tests/test_goodman_focus.py::GetPeaksTest::test_single_peak goodman_focus/tests/test_goodman_focus.py::GoodmanFocusTests::test__call__ goodman_focus/tests/test_goodman_focus.py::GoodmanFocusTests::test__fit goodman_focus/tests/test_goodman_focus.py::GoodmanFocusTests::test_get_focus_data goodman_focus/tests/test_goodman_focus.py::DirectoryAndFilesTest::test_directory_does_not_exists goodman_focus/tests/test_goodman_focus.py::DirectoryAndFilesTest::test_directory_exists_but_empty
goodman_focus/goodman_focus.py
goodman_focus/goodman_focus.py