[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BYWD3629PMD48DVX5NE9WF":3,"skill-same:01M7BYWD3629PMD48DVX5NE9WF":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7BYWD3629PMD48DVX5NE9WF","light-curve-preprocessing",null,"Preprocessing and cleaning techniques for astronomical light curves. Use when preparing light curve data for period analysis, including outlier removal, trend removal, flattening, and handling data quality flags. Works with lightkurve and general time series data.","linyouxue\u002Fskill-repair-benchmark","linyouxue","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F216151464?v=4","01M7BJEVCXKD74KH6FG9CBVSQB","林宥学","01M7BJEVE02NP217V93BKZFC0J",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fevaluation\u002Fresults\u002FSkillAxe\u002Ftasks\u002Fexoplanet-detection-period\u002Frepaired_skill\u002Flight-curve-preprocessing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: light-curve-preprocessing\ndescription: Preprocessing and cleaning techniques for astronomical light curves. Use when preparing light curve data for period analysis, including outlier removal, trend removal, flattening, and handling data quality flags. Works with lightkurve and general time series data.\n---\n\n# Light Curve Preprocessing\n\nPreprocessing is essential before period analysis. Raw light curves often contain outliers, long-term trends, and instrumental effects that can mask or create false periodic signals.\n\n## Overview\n\nCommon preprocessing steps:\n1. Remove outliers\n2. Remove long-term trends\n3. Handle data quality flags\n4. Remove stellar variability (optional)\n\n## Outlier Removal\n\n### Using Lightkurve\n\n```python\nimport lightkurve as lk\n\n# Remove outliers using sigma clipping\nlc_clean, mask = lc.remove_outliers(sigma=3, return_mask=True)\noutliers = lc[mask]  # Points that were removed\n\n# Common sigma values:\n# sigma=3: Standard (removes ~0.3% of data)\n# sigma=5: Conservative (removes fewer points)\n# sigma=2: Aggressive (removes more points)\n```\n\n### Manual Outlier Removal\n\n```python\nimport numpy as np\n\n# Calculate median and standard deviation\nmedian = np.median(flux)\nstd = np.std(flux)\n\n# Remove points beyond 3 sigma\ngood = np.abs(flux - median) \u003C 3 * std\ntime_clean = time[good]\nflux_clean = flux[good]\nerror_clean = error[good]\n```\n\n## Removing Long-Term Trends\n\n### Flattening with Lightkurve\n\n```python\n# Flatten to remove low-frequency variability\n# window_length: number of cadences to use for smoothing\nlc_flat = lc_clean.flatten(window_length=500)\n\n# Common window lengths:\n# 100-200: Remove short-term trends\n# 300-500: Remove medium-term trends (typical for TESS)\n# 500-1000: Remove long-term trends\n```\n\nThe `flatten()` method uses a Savitzky-Golay filter to remove trends while preserving transit signals.\n\n#### Transit-preserving detrending: required sanity checks\n\nDetrending is where many wrong periods are introduced (especially harmonics like P\u002F2): if the window is too short or the method absorbs transit structure, it can reshape the transit series and make a harmonic look \"best\".\n\nBefore committing to a period found after flattening:\n\n1. **Window vs transit duration:** choose `window_length` (in cadences) so the smoothing timescale is **much longer** than the expected transit duration.\n   - Rule of thumb: smoothing window timescale ≥ **5–10×** the transit duration.\n2. **Convert days → cadences explicitly:**\n   - Estimate cadence from `median(np.diff(time))`.\n   - `window_length ≈ (window_days \u002F cadence_days)` and must be an odd integer for Savitzky–Golay.\n3. **Stability across windows:** repeat with 2–3 different windows (e.g., 0.5×, 1×, 2× your chosen window). A real planet period should remain a top candidate; a detrending-induced harmonic often shifts.\n\n### Iterative Sine Fitting\n\nFor removing high-frequency stellar variability (rotation, pulsation):\n\n```python\ndef sine_fitting(lc):\n    \"\"\"Remove dominant periodic signal by fitting sine wave.\"\"\"\n    pg = lc.to_periodogram()\n    model = pg.model(time=lc.time, frequency=pg.frequency_at_max_power)\n    lc_new = lc.copy()\n    lc_new.flux = lc_new.flux \u002F model.flux\n    return lc_new, model\n\n# Iterate multiple times to remove multiple periodic components\nlc_processed = lc_clean.copy()\nfor i in range(50):  # Number of iterations\n    lc_processed, model = sine_fitting(lc_processed)\n```\n\n**Warning**: This removes periodic signals, so use carefully if you're searching for periodic transits.\n\n## Handling Data Quality Flags\n\n**IMPORTANT**: Quality flag conventions vary by data source!\n\n### Standard TESS format\n```python\n# For standard TESS files (flag=0 is GOOD):\ngood = flag == 0\ntime_clean = time[good]\nflux_clean = flux[good]\nerror_clean = error[good]\n```\n\n### Alternative formats\n```python\n# For some exported files (flag=0 is BAD):\ngood = flag != 0\ntime_clean = time[good]\nflux_clean = flux[good]\nerror_clean = error[good]\n```\n\n**Always verify your data format!** Check which approach gives cleaner results.\n\n## Preprocessing Pipeline Considerations\n\nWhen building a preprocessing pipeline for exoplanet detection:\n\n### Key Steps (Order Matters!)\n\n1. **Quality filtering**: Apply data quality flags first\n2. **Outlier removal**: Remove bad data points (flares, cosmic rays)\n3. **Trend removal**: Remove long-term variations (stellar rotation, instrumental drift)\n4. **Optional second pass**: Additional outlier removal after detrending\n\n### Important Principles\n\n- **Always include flux_err**: Critical for proper weighting in period search algorithms\n- **Preserve transit shapes**: Use methods like `flatten()` that preserve short-duration dips\n- **Don't over-process**: Too aggressive preprocessing can remove real signals\n- **Verify visually**: Plot each step to ensure quality\n\n### Parameter Selection\n\n- **Outlier removal sigma**: Lower sigma (2-3) is aggressive, higher (5-7) is conservative\n- **Flattening window**: Should be longer than transit duration but shorter than stellar rotation period\n- **When to do two passes**: Remove obvious outliers before detrending, then remove residual outliers after\n\n## Preprocessing for Exoplanet Detection\n\nFor transit detection, be careful not to remove the transit signal:\n\n1. **Remove outliers first**: Use sigma=3 or sigma=5\n2. **Flatten trends**: Use window_length appropriate for your data\n3. **Don't over-process**: Too much smoothing can remove shallow transits\n\n## Visualizing Results\n\nAlways plot your light curve to verify preprocessing quality:\n\n```python\nimport matplotlib.pyplot as plt\n\n# Use .plot() method on LightCurve objects\nlc.plot()\nplt.show()\n```\n\n**Best practice**: Plot before and after each major step to ensure you're improving the data quality, not removing real signals.\n\n## Dependencies\n\n```bash\npip install lightkurve numpy matplotlib\n```\n\n## References\n\n- [Lightkurve Preprocessing Tutorials](https:\u002F\u002Flightkurve.github.io\u002Flightkurve\u002Ftutorials\u002Findex.html)\n- [Removing Instrumental Noise](https:\u002F\u002Flightkurve.github.io\u002Flightkurve\u002Ftutorials\u002F2.3-removing-noise.html)\n\n## Best Practices\n\n1. **Always check quality flags first**: Remove bad data before processing\n2. **Remove outliers before flattening**: Outliers can affect trend removal\n3. **Choose appropriate window length**: Too short = doesn't remove trends, too long = removes transits\n4. **Visualize each step**: Make sure preprocessing improves the data\n5. **Don't over-process**: More preprocessing isn't always better\n","# Light Curve Preprocessing\n\nPreprocessing is essential before period analysis. Raw light curves often contain outliers, long-term trends, and instrumental effects that can mask or create false periodic signals.\n\n## Overview\n\nCommon preprocessing steps:\n1. Remove outliers\n2. Remove long-term trends\n3. Handle data quality flags\n4. Remove stellar variability (optional)\n\n## Outlier Removal\n\n### Using Lightkurve\n\n```python\nimport lightkurve as lk\n\n# Remove outliers using sigma clipping\nlc_clean, mask = lc.remove_outliers(sigma=3, return_mask=True)\noutliers = lc[mask]  # Points that were removed\n\n# Common sigma values:\n# sigma=3: Standard (removes ~0.3% of data)\n# sigma=5: Conservative (removes fewer points)\n# sigma=2: Aggressive (removes more points)\n```\n\n### Manual Outlier Removal\n\n```python\nimport numpy as np\n\n# Calculate median and standard deviation\nmedian = np.median(flux)\nstd = np.std(flux)\n\n# Remove points beyond 3 sigma\ngood = np.abs(flux - median) \u003C 3 * std\ntime_clean = time[good]\nflux_clean = flux[good]\nerror_clean = error[good]\n```\n\n## Removing Long-Term Trends\n\n### Flattening with Lightkurve\n\n```python\n# Flatten to remove low-frequency variability\n# window_length: number of cadences to use for smoothing\nlc_flat = lc_clean.flatten(window_length=500)\n\n# Common window lengths:\n# 100-200: Remove short-term trends\n# 300-500: Remove medium-term trends (typical for TESS)\n# 500-1000: Remove long-term trends\n```\n\nThe `flatten()` method uses a Savitzky-Golay filter to remove trends while preserving transit signals.\n\n#### Transit-preserving detrending: required sanity checks\n\nDetrending is where many wrong periods are introduced (especially harmonics like P\u002F2): if the window is too short or the method absorbs transit structure, it can reshape the transit series and make a harmonic look \"best\".\n\nBefore committing to a period found after flattening:\n\n1. **Window vs transit duration:** choose `window_length` (in cadences) so the smoothing timescale is **much longer** than the expected transit duration.\n   - Rule of thumb: smoothing window timescale ≥ **5–10×** the transit duration.\n2. **Convert days → cadences explicitly:**\n   - Estimate cadence from `median(np.diff(time))`.\n   - `window_length ≈ (window_days \u002F cadence_days)` and must be an odd integer for Savitzky–Golay.\n3. **Stability across windows:** repeat with 2–3 different windows (e.g., 0.5×, 1×, 2× your chosen window). A real planet period should remain a top candidate; a detrending-induced harmonic often shifts.\n\n### Iterative Sine Fitting\n\nFor removing high-frequency stellar variability (rotation, pulsation):\n\n```python\ndef sine_fitting(lc):\n    \"\"\"Remove dominant periodic signal by fitting sine wave.\"\"\"\n    pg = lc.to_periodogram()\n    model = pg.model(time=lc.time, frequency=pg.frequency_at_max_power)\n    lc_new = lc.copy()\n    lc_new.flux = lc_new.flux \u002F model.flux\n    return lc_new, model\n\n# Iterate multiple times to remove multiple periodic components\nlc_processed = lc_clean.copy()\nfor i in range(50):  # Number of iterations\n    lc_processed, model = sine_fitting(lc_processed)\n```\n\n**Warning**: This removes periodic signals, so use carefully if you're searching for periodic transits.\n\n## Handling Data Quality Flags\n\n**IMPORTANT**: Quality flag conventions vary by data source!\n\n### Standard TESS format\n```python\n# For standard TESS files (flag=0 is GOOD):\ngood = flag == 0\ntime_clean = time[good]\nflux_clean = flux[good]\nerror_clean = error[good]\n```\n\n### Alternative formats\n```python\n# For some exported files (flag=0 is BAD):\ngood = flag != 0\ntime_clean = time[good]\nflux_clean = flux[good]\nerror_clean = error[good]\n```\n\n**Always verify your data format!** Check which approach gives cleaner results.\n\n## Preprocessing Pipeline Considerations\n\nWhen building a preprocessing pipeline for exoplanet detection:\n\n### Key Steps (Order Matters!)\n\n1. **Quality filtering**: Apply data quality flags first\n2. **Outlier removal**: Remove bad data points (flares, cosmic rays)\n3. **Trend removal**: Remove long-term variations (stellar rotation, instrumental drift)\n4. **Optional second pass**: Additional outlier removal after detrending\n\n### Important Principles\n\n- **Always include flux_err**: Critical for proper weighting in period search algorithms\n- **Preserve transit shapes**: Use methods like `flatten()` that preserve short-duration dips\n- **Don't over-process**: Too aggressive preprocessing can remove real signals\n- **Verify visually**: Plot each step to ensure quality\n\n### Parameter Selection\n\n- **Outlier removal sigma**: Lower sigma (2-3) is aggressive, higher (5-7) is conservative\n- **Flattening window**: Should be longer than transit duration but shorter than stellar rotation period\n- **When to do two passes**: Remove obvious outliers before detrending, then remove residual outliers after\n\n## Preprocessing for Exoplanet Detection\n\nFor transit detection, be careful not to remove the transit signal:\n\n1. **Remove outliers first**: Use sigma=3 or sigma=5\n2. **Flatten trends**: Use window_length appropriate for your data\n3. **Don't over-process**: Too much smoothing can remove shallow transits\n\n## Visualizing Results\n\nAlways plot your light curve to verify preprocessing quality:\n\n```python\nimport matplotlib.pyplot as plt\n\n# Use .plot() method on LightCurve objects\nlc.plot()\nplt.show()\n```\n\n**Best practice**: Plot before and after each major step to ensure you're improving the data quality, not removing real signals.\n\n## Dependencies\n\n```bash\npip install lightkurve numpy matplotlib\n```\n\n## References\n\n- [Lightkurve Preprocessing Tutorials](https:\u002F\u002Flightkurve.github.io\u002Flightkurve\u002Ftutorials\u002Findex.html)\n- [Removing Instrumental Noise](https:\u002F\u002Flightkurve.github.io\u002Flightkurve\u002Ftutorials\u002F2.3-removing-noise.html)\n\n## Best Practices\n\n1. **Always check quality flags first**: Remove bad data before processing\n2. **Remove outliers before flattening**: Outliers can affect trend removal\n3. **Choose appropriate window length**: Too short = doesn't remove trends, too long = removes transits\n4. **Visualize each step**: Make sure preprocessing improves the data\n5. **Don't over-process**: More preprocessing isn't always better\n",{"name":5,"description":7},"main","cdcb6d230f3b15c3c33f8a2bdd16439f43602cbe","evaluation\u002Fresults\u002FSkillAxe\u002Ftasks\u002Fexoplanet-detection-period\u002Frepaired_skill\u002Flight-curve-preprocessing",1,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark","https:\u002F\u002Fgithub.com\u002Flinyouxue","2026-11-14 20:28:35",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add linyouxue\u002Fskill-repair-benchmark --skill light-curve-preprocessing",{"tool":37,"command":38},"bunx","bunx skills add linyouxue\u002Fskill-repair-benchmark --skill light-curve-preprocessing",{"tool":40,"command":41},"pnpm","pnpm dlx skills add linyouxue\u002Fskill-repair-benchmark --skill light-curve-preprocessing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fevaluation\u002Fresults\u002FSkillAxe\u002Ftasks\u002Fexoplanet-detection-period\u002Frepaired_skill\u002Flight-curve-preprocessing\u002FSKILL.md",true,[],[46,53,60,67,72,77],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7E1HGVRY73NBJ022CJG13X6","video-frame-extraction","Extract frames from video files and save them as images using OpenCV","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7E1HAG5R7CJ9C8NYJS771MB","openai-vision","Analyze images and multi-frame sequences using OpenAI GPT vision models","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7E1H7DADKB6QBWKC2KQ63SZ","image-ocr","Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[],{"skillNo":68,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M7E1H0WBNT43TENGQY7AVZHD","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":73,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7E1GTC7D4N4Q2EF03875J9E","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":78,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7E1GQ92CWFMGH53KSSE4WER","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[]]