taken from suvi code by vhsu
        Parse the metadata from a product filename, either L1b or l2.
           - file start
           - file end
           - platform
           - product

        :param filename: string filename of product
        :return: (start datetime, end datetime, platform)

def parse_filename_meta(filename):
        """
        taken from suvi code by vhsu
        Parse the metadata from a product filename, either L1b or l2.
           - file start
           - file end
           - platform
           - product

        :param filename: string filename of product
        :return: (start datetime, end datetime, platform)
        """
        common_pattern = "_%s_%s" % (
            "(?P<product>[a-zA-Z]{3}[a-zA-Z]?-[a-zA-Z0-9]{2}[a-zA-Z0-9]?-[a-zA-Z0-9]{4}[a-zA-Z0-9]?)",
            # product l1b, or l2
            "(?P<platform>[gG][1-9]{2})"  # patform, like g16
        )
        patterns = {  # all patterns must have the common componennt
            "l2_pattern": re.compile("%s_s(?P<start>[0-9]{8}T[0-9]{6})Z_e(?P<end>[0-9]{8}T[0-9]{6})Z" % common_pattern),
            "l1b_pattern": re.compile('%s_s(?P<start>[0-9]{14})_e(?P<end>[0-9]{14})' % common_pattern),
            "dayfile_pattern": re.compile("%s_d(?P<start>[0-9]{8})" % common_pattern),
            "monthfile_pattern": re.compile("%s_m(?P<start>[0-9]{6})" % common_pattern),
            "yearfile_pattern": re.compile("%s_y(?P<start>[0-9]{4})" % common_pattern),
        }
        match, dt_start, dt_end = None, None, None
        for pat_type, pat in patterns.items():
            match = pat.search(filename)
            if match is not None:
                if pat_type == "l2_pattern":
                    # parse l2
                    dt_start = datetime.strptime(match.group("start"), '%Y%m%dT%H%M%S')
                    dt_end = datetime.strptime(match.group("end"), '%Y%m%dT%H%M%S')
                elif pat_type == "l1b_pattern":
                    # parse l1b
                    dt_start = datetime.strptime(match.group("start"), '%Y%j%H%M%S%f')
                    dt_end = datetime.strptime(match.group("end"), '%Y%j%H%M%S%f')
                elif pat_type == "dayfile_pattern":
                    dt_start = datetime.strptime(match.group("start"), "%Y%m%d")
                    dt_end = dt_start + timedelta(hours=24)
                elif pat_type == "monthfile_pattern":
                    dt_start = datetime.strptime(match.group("start"), "%Y%m")
                    dt_end = datetime(dt_start.year, dt_start.month + 1,
                                      1)  # will raise exception in December, fix when needed
                elif pat_type == "yearfile_pattern":
                    dt_start = datetime.strptime(match.group("start"), "%Y")
                    dt_end = datetime(dt_start.year + 1, 1, 1)
                break

        if match is None:
            if "NCEI" in filename and ".fits" in filename:
                dt_start = datetime.strptime("T".join(filename.split("_")[4:6]), "%Y%m%dT%H%M%S")
                dt_end = dt_start
                angstroms = int(filename.split("_")[2])
                atom = "Fe" if angstroms != 304 else "He"
                product = "SUVI-L1b-{}{}".format(atom, angstroms)
                return filename, dt_start, dt_end, "g16", product
            else:
                # we didn't find any matching patterns...
                raise ValueError("Timestamps not detected in filename: %s" % filename)
        else:
            return filename, dt_start, dt_end, match.group("platform"), match.group("product")