def readfitfile_comments(fitfilepath):
    """read comments and return corresponding strings
    #CCDLabel
    #pixelsize
    #Frame dimensions
    #DetectorParameters
    """
    dictcomments = {}
    ccdlabelflag = False
    pixelsizeflag = False
    framedimflag = False
    detectorflag = False
    f = open(fitfilepath, 'r')
    nblines = 0
    for line in f.readlines():
        nblines += 1
    f.seek(0)
    lineindex = 0
    while lineindex < nblines:
        line = f.readline()
        if ccdlabelflag:
            dictcomments['CCDLabel'] = line.split('#')[1].strip()
            ccdlabelflag = False
        if pixelsizeflag:
            dictcomments['pixelsize'] = line.split('#')[1].strip()
            pixelsizeflag = False
        if framedimflag:
            dictcomments['framedim'] = line.split('#')[1].strip()
            framedimflag = False
        if detectorflag:
            dictcomments['detectorparameters'] = line.split('#')[1].strip()
            detectorflag = False
        if line.startswith(('#CCDLabel', '# CCDLabel')):
            ccdlabelflag = True
        if line.startswith(('#pixelsize', '# pixelsize')):
            pixelsizeflag = True
        if line.startswith(('#Frame dimensions', '# Frame dimensions')):
            framedimflag = True
        if line.startswith(('#DetectorParameters', '# DetectorParameters')):
            detectorflag = True
        lineindex += 1
    f.close()
    return dictcomments
